Woocommerce pre_get_posts query variation meta data not working
Woocommerce pre_get_posts query variation meta data not working
Woocommerce pre_get_posts query variation meta data not working
Exclude taxonomy Query if post_type
pre_get_posts fix to show menu on CPT Archives broken WP 6.0
Elementor posts custom query based on tag [closed]
WP_Query, Paginate by Custom Field
$wp_query->found_posts not returning correct value
Welcome to the community 🙂 Generally speaking, the WP_Query is quite a central piece of everything in WordPress, so I’d recommend first getting a solid understanding of what is going on inside the core before tinkering too much with WP_Query as it will often have undesired side-effects which are hard to understand & debug. Having … Read more
tax_query in pre_get_posts
I figured it out, here is the solution for anyone else wondering how to do something like this: function force_ID($query) { global $wpdb; if (substr($_SERVER[‘REQUEST_URI’],-5) == ‘.html’) { $post_id = $wpdb->get_var($wpdb->prepare(“SELECT ID FROM $wpdb->posts WHERE post_name=%s AND post_status=”publish””,substr(basename($_SERVER[‘REQUEST_URI’]),0,-5))); if ($post_id > 0) $query->set(‘page_id’,$post_id); } } add_action(‘pre_get_posts’,’force_ID’); In examining the wp-includes/query.php file, I noticed that the … Read more
For some use cases, couldn’t you use $query->get() to target specific custom queries? For example: say you’ve got a custom query for a slider post-type. Perhaps something like this? function wpse64950_filter_pre_get_posts( $query ) { if ( ! is_main_query() ) { if ( ‘slider’ == $query->get( ‘post-type’ ) ) { // This is a query of … Read more