I have this wp_query but it only returns 1 post. I want it to return anything in the ‘directory’ category with the tag ‘pick’. I know there can be problems with posts_per_page, but nothing is working (I’ve searched a lot) to get the query to display more than one post. Any help would be great.

<?php // The Query

            wp_reset_query();

            global $wp_query;

            $term = $wp_query->queried_object;

            $args=array(
                'ignore_sticky_posts' => true,
                'posts_per_page' => -1,
                'post_type' => 'directory',
                'suppress_filters' => true,
                'tag' => 'picks',
                'tax_query' => array(
                array(
                    'taxonomy'  => $term->taxonomy,
                    'field'     => 'slug',
                    'terms'     => $term->slug,
                    )
                )
            );

            $new_query = new WP_Query($args);

        if ( $new_query->have_posts()) : $new_query->the_post(); ?>

            <article <?php post_class('post-tile'); ?>>
                <a href="<?php the_permalink() ?>" rel="bookmark">
                <?php
                    $post_thumbnail_id = get_post_thumbnail_id( );
                    $imagesized = wp_get_attachment_image_src( $post_thumbnail_id, 'big-post-thumb');
                    if ($imagesized[1] == 308) {
                        the_post_thumbnail('big-post-thumb');
                    } else {
                        the_post_thumbnail('cat-post-thumb');
                    }
                ?>
                <h3><?php the_title(); ?></h3>
                <div class="intro">
                    <p><?php echo get_excerpt(140); ?></p>
                </div>
                </a>
            </article>
            <?php wp_reset_postdata(); else : ?>
            <p>No picks as yet&hellip;</p>
        <?php endif; ?>

    </div>

Read more here: posts_per_page only returning one post


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: