• Resolved hilj

    (@hilj)


    I have three kind of a Posts in my page:

    -Blog post, shown by the single_blog.php
    -News post, shown by the sidebar02.php
    -Events post, shown by singe.php

    Now the posts_nav_link browses through all these categories. For instance when I’m browsing through events and when I reach the oldest event, it starts showing the blog Posts.

    I would like to exclude and include categories from it, can it be done?

    Codex article was mainly about styling. https://codex.www.ads-software.com/Next_and_Previous_Links

    Help appreciated, thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • My suspicion is that the template tag doesn’t behave as expected because of your non-standard template file names.

    On a normal setup (using either the archive.php or Category_Templates to display category archives) the Template_Tags/posts_nav_link never displays posts from other categories when browsing a cat archive/listing.

    Thread Starter hilj

    (@hilj)

    Okay, that makes sense.

    I simply tried to ad a number in the end, like this: single2.php, sidebar2.php no effect, it still browses trough all Posts.

    What should I call them then? Or should I build it somehow differently?

    Thank you for this.

    I don’t see how you could do this through posts_nav_link(), as it’s really only ‘page’ aware. The portion of the posts query it builds off of is the part that lets it determine if any posts are extant for say previous links and the like.

    Not knowing how these various posts types are discriminated and displayed in your code, I can only suggest rethinking how they are queried, say through the use of query_posts().

    Thread Starter hilj

    (@hilj)

    Ouch! I made a mistake. I was talking about the next_post_link and previous_post_link. I got mixed up when I searched with a previou_post_link and the result was the “next and previous links” article and not the “previous post link” article.

    next and previous_post_link lets me exclude categories just as I wanted.

    There’s one litle really basic thing I couldn’t figure:

    <?php previous_post_link('&larr; %link','past', FALSE, '18 and 17'); ?>

    The link is named “past”, I would like to see a post title there. I know the %link is just that, but if I leave “past” empty, like this:

    <?php previous_post_link('&larr; %link','', FALSE, '18 and 17'); ?>

    Nothing happens (obviously cause it’s empty) what should I put there to ignore it?

    Thanks a lot for these. And sorry for mixing up the mix up.

    <?php previous_post_link('&larr; %link','%title', FALSE, '18 AND 17'); ?>

    That would provide the title of the (in this case previous) post as your link text.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘posts_nav_link should include only one category?’ is closed to new replies.