Wordpress custom sort by meta key - wordpress

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

Related

How to add a custom field to wpgraphql existing query

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

How to get tags with custom taxonomy field?

I have added custom taxonomy fields on tags but when I use get_tags() it does not return custom field. Right now I am using get_term_meta() for custom field but I have 4000 records of tags so when I fire the query to get tags it fires 4000 queries so any way to minimise it or get results in 1 query with get_tags().
Try to use get_term_by this will help you to get term meta value using many different ways.
For more detail check this https://codex.wordpress.org/Function_Reference/get_term_by

WordPress - Get Comments by Meta Data?

I have developed a custom plugin.
I need a comment option for my plugin.
I have passed a key value as meta key.
In the comment list, it displays all the comments for the particular page, but I want it to display the comments based on the meta key.
Is this possible?

Get post IDs that contain a search term in wp_posts or in the custom_fields for the ID

I need to return the IDs for all WordPress posts that contain a search term either in the wp_posts fields for that ID or in any of the custom fields that are linked to that ID. I can't think of an SQL query to do this so I'm faced with doing something like using get_post_meta($ID,'') to bring back all the custom fields for an ID, and then searching all of those with strstr().
But searching posts for some content seems like a fairly common thing to do in WordPress development so I'm thinking that WordPress might have something built in to help, or there's a plugin for it.
Does anyone know a good way to do this? Thanks
There's a solution to this at http://adambalee.com/search-wordpress-by-custom-fields-without-a-plugin/.

How do I sort custom taxonomy pages by custom date field in wordpress?

What I'd like to do is sort all posts that appear on pages filtered by different children of taxonomies, by a 'date' meta key.
I found this generic query_posts function:
query_posts('&meta_key=date&orderby=meta_value&order=DESC')
This grabs all the posts and places them on a single page, sorting these by my custom meta Key. I would like to still keep the pages separated by their given taxonomy/terms, but sort all of these by this date meta_key. I hope I've explained this correctly. Thank you very much, anyone who can help!

Resources