Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title

I’m working on a custom taxonomy term page template where we want the items that are connected to the term sorted by a publication date (custom date field) – and if there are multiple items on the same day (formatted like YYYY-MM-DD) to then sort those by title, and finally sort by title if the … Read more

Add validation and error handling when saving custom fields?

I have a function that defines a custom field on a post type. Say the field is “subhead”. When the post is saved, I want to do some validation on the input, and display an error message on the post edit screen if necessary. Something like: // Handle post updating function wpse_update_post_custom_values($post_id, $post) { // … Read more

Using meta query (‘meta_query’) with a search query (‘s’)

Trying to build a search that not only searches the defaults (title, content etc) but also a specific custom field. My current query: $args = array( ‘post_type’ => ‘post’, ‘s’ => $query, ‘meta_query’ => array( array( ‘key’ => ‘speel’, ‘value’ => $query, ‘compare’ => ‘LIKE’ ) ) ); $search = new WP_Query( $args ) … … Read more

Adding Fields to the Category, Tag and Custom Taxonomy Edit Screen in the WordPress Admin?

The question is “How do I add one or more fields to the Category, Tag and Custom Taxonomy Edit Screen in the WordPress Admin?” This question was asked on the wp-hackers list August 1st 2010 and I offered a solution later that day. The original asker discussed the issue again today (Aug 21) which reminded … Read more

How to filter post listing (in WP dashboard posts listing) using a custom field (search functionality)?

Despite the fact I googled a lot, I’ve not found the answer to a very simple question : I have some posts with a custom field (i.e. supplier_name). I would like to be able to search and filter my posts according to this custom field. In other words, in the admin posts listing, I would … Read more