Sort custom post types by last name in the backend

If you want to override the default- and the title ordering, and order instead by the last word in the title. /** * Override default- and title ordering in the backend, for the ‘speaker’ custom post type. * * @link https://wordpress.stackexchange.com/a/202154/26350 */ add_action( ‘pre_get_posts’, function( \WP_Query $q ) { if ( is_admin() && $q->is_main_query() && … Read more

WP_Query post at custom position

Pagination should be easy. You really just need to add pagination parameters to your query, and next/previous posts links, more or less like in another thread I posted in recently. $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $my_query = new WP_Query( array( ‘showposts’=>10, ‘paged’ => $paged ) ); // run the loop then, // pagination … Read more

Comments form custom fields order

Demo – Setup Here’s a demo how we could control the display of comment fields and their order: Let’s create a custom class: $mycf = new MyCommentFields; Then we define our extra fields: $myfields = []; $myfields[‘myaddress’] = sprintf( ‘<p class=”comment-form-myaddress”> <label for=”myaddress”>%s <span class=”required”>*</span></label> <input id=”myaddress” name=”myaddress” type=”text” size=”30″ tabindex=”5″ /> </p>’, esc_html__( ‘Address’, … Read more

Order by Custom Field date not recognized

I can’t get a meta_key parameter to pass through a GET string at all. Many other parameters that I tested do pass through, though I did not do an exhaustive test, but meta_key does not. If you want to verify that just add the following to the top of your header.php and inspect the query. … Read more

Problem ordering posts with numbers for titles numerically E.g. 1, 10, 100

Here’s code that will order posts by the post_title field, numerically. This code will affect the main query for posts on both the back end and front end. // Apply numeric post ordering for posts in admin and front end. // Adapted from https://www.fldtrace.com/custom-post-types-numeric-title-order function wpse247871_post_order( $wp_query ) { if ( $wp_query->is_main_query() && $wp_query->query[‘post_type’] == … Read more

Custom Taxonomy terms with latest post ordered by date pagination issue

to change the number of posts per page you can do it in the wp dashboard like in this picture This function on functions.php works for me function tcPostsPerPage( $query ) { if (is_home()){$query->set(‘posts_per_page’, 6);} if (is_archive()){$query->set(‘posts_per_page’, 6);} } add_action( ‘pre_get_posts’, ‘tcPostsPerPage’ ); the two 6 is limiting to 6 per page, if this doest … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)