Can a link in WordPress contain a query string that is picked up as $_POST

Looking at the pre_get_posts hook, the problem becomes apparent, the $Format variable is being pulled out of thin air: function get_all_terms($query) { if(empty($Format)) $Format=”test 1″; echo $Format; This variable is undefined, you cannot declare a variable in one file then use it in in other places like this. To do that you have to declare … Read more

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