The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

The Eternal Quesion: How to view one category post at a time, with navigation (3 posts)

  1. bsummer
    Posted 7 years ago #

    Well, I've seen this asked on this forum and other places on the web dozens of times but with no real answers, even though it seems like it would be straightforward in WP.

    Question: How do I set up a page that shows:
    1) Only 1 post at a time
    2) From only a specific category
    3) While maintaining usable navigation links to go to previous posts (in that category)

    Now hopefully this isn't obvious to me because I'm new to WP and PHP, but it seems like there are others who have the same question.

    Ideally what I'd like to have explained is:
    - what the best approach for this is
    - some example code -- in and around The Loop
    - what is the structure of the URL needed to reach this page

    My current WP sandbox environment is behind a firewall, so I can't show a page, but if that's a deal-breaker I'll work something out.

    Thanks in advance for anyone who even answers this.

  2. bsummer
    Posted 7 years ago #


  3. intricateartist
    Posted 7 years ago #

    1. Create a category template (ie. category-7.php)

    2. Use your main index template as your guide

    3. Insert something like this above your if have posts statement, replacing the category # with yours:

    <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("cat=7&posts_per_page=1&paged=$paged"); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic