Custom Query by Author field and meta

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 );

query_vars overriding WP_Query args

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

How to properly reset a nested WP_Query query

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

$WP_Query: How to display excerpt on first post only

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