WP Query to displaying date and posts for that date?

I was able to do this using the following: $args = array( ‘post_type’ => ‘show’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘show_date’, ‘order’ => ASC ); $query = new WP_Query( $args ); if( $query->have_posts() ) { $day_check = ”; while( $query->have_posts() ): $query->the_post(); $day = date(‘Y-m-d’, strtotime(get_field(‘show_date’))); if ($day != … Read more

Get taxonomy terms only of the WP_Query current posts

You’d probably do something like this $args = array( ‘post_type’ => ‘product’, ‘product_cat’ => get_queried_object() ); $query = new WP_Query( $args ); $termsInPosts = array(); if ( $query->have_posts() ) { while( $query->have_posts() ) : $query->the_post(); $postTerms = wp_get_post_terms(get_the_ID(), ‘brands’, array(‘fields’ => ‘term_id’)); foreach ($postTerms as $postTerm) if (!in_array($postTerm->term_id, $termsInPosts)) $termsInPosts[] = $postTerm->term_id; endwhile; } $marcas_terms … Read more

WP_Query is printing out only one post when posts_per_page is set to multiple

you are re-initializing the out variable that is why it shows only one product // Custom Post Type for Use Cases page slider function create_post_type() { register_post_type( ‘use_cases’, array( ‘labels’ => array( ‘name’ => __( ‘Use Cases’ ), ‘singular_name’ => __( ‘Use_Case’ ) ), ‘public’ => true, ‘has_archive’ => true, ) ); } add_action( ‘init’, … Read more

Sorting Posts | Alphabetical Order

Have you read this thread? Display all posts starting with given letter? This wouldn’t be simple to do with WP_Query and that’s unfortunate because that would help preserve pagination. // Rules $args = [‘post_type’=>’post’,’orderby’=>’name’]; // The Query $query1 = new WP_Query( $args ); // The Loop while ( $query1->have_posts() ) { $query1->the_post(); echo ‘<li>’ . … Read more

wp_query ‘s’ parameter does not work with custom post type

You can do like this, $args = array( ‘post_type’ => ‘tribe_events’, ‘post_per_page’ => get_option(‘posts_per_page’), ‘s’ => get_search_query() ); $query = new WP_Query($args); // Use new keyword and you need to use WP_Query not Wp_Query while($query->have_posts()): $query->the_post(); the_title(); endwhile;wp_reset_postdata(); I used this in search.php file. Worked without any problem.

WP_Query Ignoring `post_type` parameter

Try this <?php $args = array( ‘post_type’=>’weather_today’, ‘orderby’=>’ID’, ‘order’=>’ASC’, ‘posts_per_page’=>1 ); $query = new WP_Query( $args ); while ( $query->have_posts() ) : $query->the_post(); //loop endwhile; wp_reset_postdata(); ?>