WordPress.org

Ready to get started?Download WordPress

Forums

code for detect the next post of a subcategory (11 posts)

  1. ravi.r
    Member
    Posted 4 years ago #

    How should I code in wordpress to detect the next and previous post of a subcategory.

  2. esmi
    Forum Moderator
    Posted 4 years ago #

  3. davedg629
    Member
    Posted 4 years ago #

    I can't get this to work for subcategories. It seems to only work with top level categories.

  4. davedg629
    Member
    Posted 4 years ago #

    Here is my code:

    <?php next_post_link_menu('%link', '&laquo; Previous Project', TRUE, '6 and 7'); ?>

    The posts I want to page through are in category 5, I want to exclude categories 6 and 7. The problem is that categories 5, 6, and 7 are all children of another category.

  5. esmi
    Forum Moderator
    Posted 4 years ago #

    Have a look at the links I gave above. It's next_posts_link.

  6. ravi.r
    Member
    Posted 4 years ago #

    The codes which I used is as follows.

    <?php if (in_category('26'))

    {

    echo 'Film';

    next_post_link('%link', 'Next post', TRUE);

    previous_post_link('%link', 'Previous post', TRUE);
    }
    ?>

    This suppose to work fine, but its not working. This give the previous next post from all the categories.

    Please help me with this.

  7. ravi.r
    Member
    Posted 4 years ago #

    I have 3 posts in a subcategory named Film. I just want the navigation between these 3 posts.

  8. ravi.r
    Member
    Posted 4 years ago #

    I am stuck with this. Is there anyone who can help me with this.

  9. davedg629
    Member
    Posted 4 years ago #

    Yea, same problem I am having. The links above do not help. They only work when you are dealing with top level categories. They do not work when you want to only page through the posts in a subcategory.

  10. davedg629
    Member
    Posted 4 years ago #

    Sorry, the code I posted earlier uses the post mash filter plugin, even if i use the following code, the other categories are not excluded:

    `<?php next_post_link('%link', '« Previous Project', TRUE, '6 and 7'); ?>'

  11. ravi.r
    Member
    Posted 4 years ago #

    Hi there please do help me with this. I am stuck with my project.

    [moderated--bumps removed. Please refrain from bumping as per Forum Rules]

Topic Closed

This topic has been closed to new replies.

About this Topic