CPT is simply not displayed in the main archive with “pre_get_posts”

Okay, this is what works for me, thanks to the friendly hint of Jacob Peattie: function include_custom_post_type_archives($query) { if (is_home() && empty($query->query_vars[‘suppress_filters’])) { $query->set(‘post_type’, array( ‘post’, ‘landingpages’, )); return $query; } } add_filter(‘pre_get_posts’, ‘include_custom_post_type_archives’);

Tax query with multiple terms in pre_get_posts

Just use: ‘terms’ => $rt_cat_id I’ll work for both array and single-based values. Or you can simplify your code as follows: if( isset( $_GET[ ‘listing_cat’ ] ) ) { $tax_query[] = array( ‘taxonomy’ => ‘listing_category’, ‘field’ => ‘id’, ‘terms’ => $_GET[ ‘listing_cat’ ] ); }

Displaying number of search results for each post type

First, your callback to pre_get_posts is wrong. That is not the way that set works. If you had debugging enabled, you’d see Notices. It should be: function more_posts_per_search_page( $query ) { if ( !is_admin() && $query->is_main_query() ) { if ( $query->is_search ) { $query->set(‘posts_per_page’,500); $query->set(‘post_type’,array( ‘author’, ‘book’)); } } } add_action( ‘pre_get_posts’,’more_posts_per_search_page’ ); Second, there … Read more

Change post order by meta key, per post basis

Don’t try to make WP_Query, or SQL, do this. In the backend, don’t save artist_last_name save something like artist_sort_name instead, and set it to either first or last name accordingly, then sort on that normalized key. To sort conditionally with WP_Query— that is, to ignore my advise above and try to make WP_Query/SQL do this– … Read more

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