WordPress.org

Support

Support » How-To and Troubleshooting » Change post count for index/home page and the following pages in WP_Query loop

Change post count for index/home page and the following pages in WP_Query loop

  • brandon.matson
    Member

    @brandonmatson

    I am curious how I can throttle the number of posts to display between the home/index page and the following sequential pages generated by the WP_Query loop.

    This is the code I am currently using to set the loop and post count:

    <?php
     $my_query = new WP_Query('showposts=4'.'&paged='. $paged);
     while ($my_query->have_posts()) : $my_query->the_post();
     $do_not_duplicate[$post->ID] = $post->ID; ?>

    But I cant figure out how to change the post count once I am off of the home page. I have tried different variations of if/else is_front_page() but I have had no luck. Any help is appreciated.

Viewing 8 replies - 1 through 8 (of 8 total)
  • vtxyzzy
    Member

    @vtxyzzy

    Please explain more what you want to do, with an example. If you want to show fewer posts on the first page than on following pages, this article might help:

    http://wordpress.mcdspot.com/2010/04/01/short-first-page/

    I have not worked out how to have a longer first page.

    brandon.matson
    Member

    @brandonmatson

    Thanks thats in line with what I was looking for. Basically on this particular site I need 4 home page posts followed by 10 posts on the following pages.

    brandon.matson
    Member

    @brandonmatson

    VTX- I tried using that code from the link you provided and I got an error, “Parse error: syntax error, unexpected $end”. I checked the entire file for validation errors, missing brackets, short form tags etc but I cant find anything, the only variable is the code string you supplied any thoughts?

    vtxyzzy
    Member

    @vtxyzzy

    Put your modified file into a pastebin and post a link to it here so I can take a look.

    brandon.matson
    Member

    @brandonmatson

    Here is the link, let me know if that didnt work.

    http://pastebin.com/YSAMiPSu

    Thanks again for your help.

    vtxyzzy
    Member

    @vtxyzzy

    You are missing an endif – the second one shown below:

    .                  </div><!-- #nav-below -->
                   <?php endif; ?>
    
                </div>
             <?php endif; ?>
          </div>
    
          </div>
    
          <div id="sidebar">
             <?php get_sidebar(); ?>
          </div>
    brandon.matson
    Member

    @brandonmatson

    Ok that i think was the endif that was on line 54, I just needed to move it down.

    That seems to do it, thanks for your help.

    vtxyzzy
    Member

    @vtxyzzy

    Are you sure? I think the one on line 52 matched the if on line 46: if ( is_active_sidebar(...

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Change post count for index/home page and the following pages in WP_Query loop’ is closed to new replies.