• I know how to set the number of posts to display on the main page on the options/reading page (20 posts / 30 days / 10 posts, paged / etc. / etc.)
    Is there any way to override this choice in the php file that displays the page? For example, I want to make a different front page file (index2.php) which shows a different view. I can’t have two different values for my blog saved in the same database, so I need to override this value in one of the files. Is there an easy way to do it? Or a hard way?
    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • index2.php?posts_per_page=-1

    Thread Starter whimsy

    (@whimsy)

    I guess I should be more specific about what I want to do.
    In the index.php file, there is a “main loop” section that starts out with code like this:
    <?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
    and ends like this:
    <?php endforeach; else: ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?>
    <?php endif; ?>

    The code between those shows all the posts selected by the front page default settings in WordPress, and can be overridden by parameters like ?m=200406 or ?postsperpage=-1
    Is there any way to put a default value that selects a different number/grouping of posts in the code of the php file itself?

    Has anyone come up with a way of doing this?.. I am looking for the exact same thing.
    Im guessing it would be possible to “reverse engineer” the way $post is setup in wp-blog-header.php but it looks like a LOT of code to redo just to change the number of posts :S

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Overriding front page post display in php’ is closed to new replies.