Custom Field Order by Last Name and First Name

Your code has a few issues, some unrelated, but generally, you need named meta queries to order by multiple meta keys: $posts = get_posts( [ ‘post_type’ => ‘soldier’, ‘posts_per_page’ => 5, ‘paged’ => $soldier_paged, ‘meta_query’ => [ ‘last_name_clause’ => [ ‘key’ => ‘last_name’, ‘compare’ => ‘EXISTS’ ], ‘first_name_clause’ => [ ‘key’ => ‘first_name’, ‘compare’ => … Read more

Confusion regarding Nonce & using it in Custom Columns for Saving Checkbox Value to Post Meta

When trying to create a custom metabox, adding custom columns, managing custom columns and finally saving the post. Where do we need to pass the nonce. To make my question clearer. This is not correct, you shouldn’t need a nonce in a metabox because all that information is sent at once in the full request … Read more

Change Featured Image / Thumbnail CMS Description

The following will add help text to the initial “Set featured image” text. Add the following to your theme’s functions.php. Replace “Your custom text goes here” with your help text. Tested and works. function custom_featured_image_text( $content ) { return ‘<p>’ . __(‘Your custom text goes here’) . ‘</p>’ . $content; } add_filter( ‘admin_post_thumbnail_html’, ‘custom_featured_image_text’ ); … Read more

Subpages for Custom Post Type. Does that even exist?

When you register post type with register_post_type, you can set hierarchical argument. hierarchical – (boolean) (optional) Whether the post type is hierarchical (e.g. page). Allows Parent to be specified. The ‘supports’ parameter should contain ‘page-attributes’ to show the parent select box on the editor page. Default: false Note: this parameter was intended for Pages. Be … Read more

Using The REST API How To Pull All Custom Posts?

The filter is dynamic, i.e. generated from rest_{$post_type}_query. So for the post post type it’s rest_post_query and for the cpt post type it’s rest_cpt_query Note that REST pagination is available: https://example.com/wp-json/wp/v2/posts?per_page=100&page=1 https://example.com/wp-json/wp/v2/posts?per_page=100&page=2 … The maximum of per_page is to reduce the risk of fatal errors if available resources are exceeded when too many items are … Read more

List Post Title by Last Word Then Second Last

I think I got it!!! Try this: $orderby = ” SUBSTRING_INDEX( {$wpdb->posts}.post_title, ‘ ‘, -1 ) ” . $get_order. ” , {$wpdb->posts}.post_title ” . $get_order; Basically it’s sorting by lastname and then first name in 1 query. So, your whole code would be: add_filter( ‘posts_orderby’, function( $orderby, \WP_Query $q ) { if( ‘wpse_last_word’ === $q->get( … Read more