• 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)
  • 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:

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

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

    Thread Starter brandon.matson

    (@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.

    Thread Starter brandon.matson

    (@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?

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

    Thread Starter brandon.matson

    (@brandonmatson)

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

    https://pastebin.com/YSAMiPSu

    Thanks again for your help.

    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>
    Thread Starter brandon.matson

    (@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.

    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.