Custom wp_query for related posts with cmb2
Custom wp_query for related posts with cmb2
Custom wp_query for related posts with cmb2
ok,so I digged into wp-includes/query.php,and found this on line 3180: if ( is_user_logged_in() ) { // Add private states that are limited to viewing by the author of a post or someone who has caps to read private states. $private_states = get_post_stati( array(‘private’ => true) ); foreach ( (array) $private_states as $state ) $where .= … Read more
By adding another array $args = array( ‘post_type’ => ‘custom_post_type’, ‘meta_query’ => array( array( ‘key’ => ‘size’, ‘value’ => ‘big’, ‘compare’ => ‘LIKE’, ), array( ‘key’ => ‘gender’, ‘value’ => ‘male’, ), ) ); $query = new WP_Query( $args );
Unfortunately you cannot perform a meta_query using a LIKE comparison on the meta_key value when using WP_Query. I’ve been down this road… Instead you have a couple other options if you want to maintain like status relationships as post meta and not user meta and or meta in a custom table. Option 1 requires no … Read more
Query with search and subscribers only output
I don’t think this is doing what you think it’s doing, but there’s a trivial solution Use The s parameter with a pre_get_posts filter Using s as the name of your input will allow you to do a direct search via the main query, speeding up the page load. Additionally, you can then modify the … Read more
This touches upon an answer provided here Loop within a loop? except I posted the full code: $query = new WP_Query($args); while ($query->have_posts()) : // initialization for $inner_args & backup the current global $post global $post; $backup = $post; $inner_query = new WP_Query($inner_args); while ($inner_query->have_posts()) : // do something endwhile; $inner_query->reset_postdata(); // restore the global … Read more
Pull it out of the content-part. That would be the easiest. <section id=”featured”> <?php // Start custom loop $args = array( ‘post_type’ => ‘project’, ‘posts_per_page’ => 5, ); $featured_query = new WP_Query( $args ); while ( $featured_query->have_posts() ) : $featured_query->the_post(); ?> <article class=”project”> <?php if ( has_post_thumbnail() ) { the_post_thumbnail( ‘post-thumbnail’, array( ‘class’ => ‘featured’ … Read more
Should wp_query automatic meta and term cache priming be used in an enviroment with an object caching
Try – > ‘cache_results’ => false $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ =>-1, ‘product_cat’ => $catename, ‘orderby’ => ‘ASC’,’hide_empty’=> 1, ‘cache_results’ => false );