How to display more listings in WordPress

98 views Asked by At

I'm having an issue with the listings in the WordPress site I'm working on.

I have three listings only showing up out of 6. I can't seem to figure out how to make all of them display. This is using the twentyeleven WordPress theme.

enter image description here

The arrows on the right are used to move the gallery back and forth. Only one more shows up on the right side.

Here's the code I believe is generating it.

<?php if ( have_posts() ) : ?>

    <?php twentyeleven_content_nav( 'nav-above' ); ?>

    <?php if ( is_home() ) {
    query_posts($query_string . '&cat=-3');
    }
    ?>

    <?php 

    $page_name="Articles";

    $page=get_page_by_title($page_name);

    //echo $page->ID;

    query_posts( 'cat=-1,-2' );
    ?>

    <?php /* Start the Loop */ ?>
    <?php while ( have_posts() ) : the_post(); ?>

        <?php get_template_part( 'content', get_post_format() ); ?>
    <?php endwhile; ?>

    </div>

Any help would be great, thanks.

1

There are 1 answers

3
Matthew R. On

Change your query_posts() function to the following:

query_posts( 'cat=-1,-2&posts_per_page=6' ); // You can change the post_per_page variable as needed

However, I would suggest using an $args array instead of a querystring to make your query. The same query would look like this:

$args = array(
    'cat'             => array( -1, -2 ),
    'posts_per_page'  => 6
);
query_posts($args);

It is much more readable and easier to update. Also, it's worth mentioning, you are adding a negative operator to your categories. In the query_posts function, that will exclude a category. You may only be getting 3 posts because you are excluding posts from your query.