?paged=x, all the pages appear the same (7 posts)

  1. marc0047
    Posted 10 years ago #

    I think I'm inching closer to solving my overall posts navigation problem. This might be the key!

    I have created a page in the root WP directory (as opposed to the Themes folder) that brings up posts from a specific category. So far I have been able to get the posts to output correctly. I'm using a " query_posts('cat=3') " to restrict the posts to output from category 3, and as much as I'd like to restrict the posts using '&showposts=4', I'm letting WP handle this from the admin panel to reduce the amount of variables to solve.

    The Loop:
    <?php query_posts('cat=3'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php endwhile; ?>
    <div class="navigation">
    <div class="alignleft"><?php posts_nav_link('','','« Previous Entries') ?></div>
    <div class="alignright"><?php posts_nav_link('','Next Entries »','') ?></div>

    The Output:
    Four most recent posts from category 3 only are displayed, which is the desired effect.

    The problem:
    Selecting 'Previous Entries', or specifically ?paged=2, renders the same four posts when ?paged=1 is called.

    If anyone has tips, it'd be greatly appreciated.

    *** While I'm still struggling to figure this out, others have benefitted from my continual woes. If you've come upon this post with a similar problem, you maybe able to find a solution at the following threads:


  2. skippy
    Posted 10 years ago #

    Your <?php query_posts('cat=3'); ?> is clobbering the ?paged=1 that is passed on the query string.

    The solution to your problem may be simpler than you expected:
    if you want a seperate presentation just for posts in category 3, create a file in your theme directory named category-3.php. For now, simply copy your index.php to category-3.php, and then try to load that category in your browser.

    See the Category Templates documentation for more.

    If I've completely mis-understood what you want to accomplish, please let me know, and I'll try again!

  3. marc0047
    Posted 10 years ago #

    Nope, you've got it! However, I really would like to avoid using the themes set up.

    There's a special page on the site that is called 'Case Studies' that I would like to be retreived as 'http://domain.com/casestudies.php' as opposed to 'http://domain.com/wp-content/themes/mythemes/category-3.php'.

    Is there any way to write code for a page that exists in the root directory of the WP folder? Or am I just being really stubborn, and I really need to use Themes? ;)

  4. skippy
    Posted 10 years ago #

    Using themes makes it easier to do what you want without a lot of jiggery-pokery with query strings.

    You could make a rewrite rule so that requests for /casestudes.php actually receive the contents of your category-3.php file.

    Or you could use a Page Template, and then make /castestudies/ a WordPress page using the appropriate Page Template.

  5. marc0047
    Posted 10 years ago #

    I'll give those a try. Thanks again!

  6. marc0047
    Posted 10 years ago #

    Argh,... doesn't work if you reference a document like this:


    No sure what is going on. However, I did figure out another way to handle using a non-Themes page to query what I wanted. Rather than querying inside the doc, I just made sure the link queried the content I was looking for:

    Case Studies

    I'm not sure why this works properly to both display the correct posts *and* get the posts_nav_link to show up and function properly, as opposed to posts_query?! I'll investigate more!

  7. moshu
    Posted 10 years ago #

    You cannot link directly to a template like you've tried:

    Think of templates as "empty" containers which provide the structure, the framework of your displayed webpage (post, Page, whatever).

Topic Closed

This topic has been closed to new replies.

About this Topic