Inherit args from the main wp_query or wp_comment_query to my custom query
Inherit args from the main wp_query or wp_comment_query to my custom query
Inherit args from the main wp_query or wp_comment_query to my custom query
Don’t think the effort worth it to do it with generating appropriate mysql statements as you can just use three queries, or sort the posts after you have the results of the query with both ways resulting in a mostly readable code. Main reason not to choose the above is if performance is critical. Another … Read more
You can use get_the_ID() to retrieve the current page’s ID. $current_page_id = get_the_ID(); $args = array( ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘post_parent’ => ‘2’, ‘post__not_in’ => array( 4, $current_page_id ), ‘order’ => ‘ASC’, ‘orderby’ => ‘menu_order’ ); This kind of ID exclusion may cause query performance issues, especially when you have a great number … Read more
How to prevent random 302 canonical-ish redirect on custom template
$wp_query->found_posts; returns zero
Block Editor – WordPress 6.1 – CPT Archive Issue – While the title changes in the loop, all records display the same data
You could try something like this below. Basically, if we are performing a search and it is the main_query (the query that generates the page results) ignore the default search and perform an exact match via the query_where function custom_product_search_exact_match( $query ) { global $wpdb; if ( is_search() && is_main_query() && !empty( $query->query_vars[‘s’] ) ) … Read more
For array and object meta values, WordPress serializes them to string representations using serialize(). Thus, your meta value looks like this in the database: a:3:{i:0;s:9:”1 | 1 | 1″;i:1;s:15:”1.5 | 1.5 | 1.5″;i:2;s:12:”22 | 22 | 22″;} There is no built-in way to query within these serialized strings, but since these are strings with a … Read more
Your query there is looking for results from either post type that have the meta value. AFAIK there’s no way to do that in a single query unless you also add the checkbox to the other post type.
WP_Query on custom taxonomy -> Location and Activity