I have a problem in posts query, I want to add a new key likes to the existing posts query to count total number likes to the particular post.
Is there any hooks to do it??
I have tried with another custom query to get post like by post id but need to add that key to that existing posts query.
enter image description here
Related
I am using wpgraphql to communicate with wordpress database. I have got one posts table in which I can see all the attributes of the post filled. There is a field for custom field too, I can see the value filled for custom field in the postMeta table ,but cannot get the meta field attribute in the subfield of the posts in the graphql query.
I am working on a woocommerce project with little bit knowledge on wordpress. Now, I have got a requirement which is shared below:
1. Show date calendar on product listing page top of list not in sidebar. I am saving product availiblity based on date ranges in separate table. This table has product id, date start and date end.
2. Show sizes dropdown on product listing on top of list. Sizes filter is already showing in sidebard but client wants it on top. So, I wil disable it in sidebar.
3. When customer will select date and size, product list should be filter accordingly.
I have read wordpress documentation where wc_query has option to use either "EXISTS or NOT Exists" through ws_meta_query. But I am not able to understand, how can I put filter on product query using either "EXISTS or NOT EXISTS" with my custom raw query?
Can someone please guide me how can I implement whole requirement along with how can I EXISTS using raw sql query with product query?
Thanks in Advance
For first 2 points, you'll need woocommerce_before_shop_loop action to display your custom filters.
and for 3rd point, you'll need pre_get_posts action to control your queries.
We have created many pages in Wordpress and want to add an employee (name, phone, email etc.) to every page as responsible contact person. Now we want to add every contact person once in the backend and choose the right person in the page.
We also use Advanced Custom Fields (ACF) and could add a Field for adding the data, but it could be difficult if the employee gets a new phone number for example.
Has anyone an idea how to solve it in wordpress?
My proposition is:
Add custom post type named "Employees" to your WordPress.
Add custom fields (based on ACF) for contact data and assign them to mentioned post type.
Add post object field to your pages and assign employees post type to this field.
And it's done! Now you can assign a specific employee to your page as a post object and display data from it, like this.
I have a WordPress query that I need to pull out the posts that have a custom meta key of "original-document". In short I need to have all of the posts with the meta key value in 1 column and the rest of the results in another column. Any ideas on how I can accomplish this?
You can use query posts:
query_posts('meta_key=original-document&orderby=meta_value');
See http://codex.wordpress.org/Function_Reference/query_posts
I am attempting to have lots of posts in a specific category. The post will have a custom field that will be a date. I need the posts to be organized by the category, the custom field, and each page of posts should be separated by month of the custom field. So hard to explain...
Page of posts for the current month. Links at the bottom for Previous and Next month. Sorted by custom field, not post date. And it should only be in the specific category.
Any ideas on what I can do to achieve this?
There are several things you can do. If you want to sort it by date, you could just modify the published date in the right sidebar of the Add Post screen.
If you want posts to be only from a certain category you can create a custom query like this
query_posts('category_name=My Category');
And then order by your custom field using: orderby=meta_value
So the full query is:
query_posts('category_name=My Category&orderby=meta_value&meta_key=dateField')
Hopefully that helps you get on the right track.
Documentation:
http://codex.wordpress.org/Function_Reference/get_post_meta
http://codex.wordpress.org/Function_Reference/query_posts