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

    Background:
    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(); ?>
    [content]
    <?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>
    </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:

    https://www.ads-software.com/support/topic/37547
    https://www.ads-software.com/support/topic/38210

Viewing 6 replies - 1 through 6 (of 6 total)
  • 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!

    Thread Starter marc0047

    (@marc0047)

    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 ‘https://domain.com/casestudies.php&#8217; as opposed to ‘https://domain.com/wp-content/themes/mythemes/category-3.php&#8217;.

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

    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.

    Thread Starter marc0047

    (@marc0047)

    I’ll give those a try. Thanks again!

    Thread Starter marc0047

    (@marc0047)

    Argh,… doesn’t work if you reference a document like this:

    https://domain.com/wp-content/themes/mythemes/category-3.php

    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!

    You cannot link directly to a template like you’ve tried:
    https://example.com/wp-content/themes/mythemes/category-3.php

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘?paged=x, all the pages appear the same’ is closed to new replies.