• The Codex examples for next_post_link infer that you can both restrict the link to the current category by making the third parameter ‘true’ and exclude categories with the fourth parameter.

    This is not working for me, however. I can do one or the other, but not both.

    I am wondering if the function broke somewhere along the way as it seems to have worked at one time.

    For what it’s worth, I am not the only one who seems to suspect that this is the case.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Are you sure you are using the tag properly?

    " and "

    you have to use the *and* delimiter with the quotes. Can you please try this and if it does not work then post your code here?

    Thread Starter submon

    (@submon)

    I fiddled with the code into many different configurations while trying to get it working. I did try ” and ” as the separator, as well as “, ” just in case. Of course, I also tried excluding only one category ID, which also did not work. Bottom line is when a post is in 2 categories—in this case, “Blog” and “Mini Feature”, I can not exclude “Mini Feature” while restricting the links to “blog” (the current category).

    As far as my code, I do not have any code since I did not find something that worked. I started with this, though:

    <?php next_post_link('%link', 'Next post in category', TRUE, '13'); ?>

    This came from the Codex examples, and the only thing I changed was the category ID to ’11’. This code does not work for me on a new WordPress 2.8.1 installation.

    same question with wordpress mu 2.8.2
    filter previous_post_link and filter next_post_link work exclusively.

    did u find the solution?

    I was experiencing this problem and I tracked it down.
    First of all, from what I saw, it is INCORRECT to say that the delimiter should be:
    " and "

    Meaning with quotes. There should be no quotes, it should just be
    and

    That is, a space, the word ‘and’, and then another space.

    Either way, this was NOT working for me. I do not know why, but PHP was not running the explode() function correctly on my string, which appeared to be delimited correctly.

    I hacked the WordPress code on line 884 of /wp-includes/link-template.php and changed where it said:
    array_map('intval', explode(' and ', $excluded_categories));
    to be:
    array_map('intval', explode('|', $excluded_categories));

    And then in my own code for the next_post_link() function, I did it like this:
    next_post_link('%link', 'Next Post &raquo;', FALSE, '7|3|4');

    It used to say ‘7 and 3 and 4’. Now it says ‘7|3|4’. Got it? Mine’s working okay now.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Is next_post_link category exclude broken?’ is closed to new replies.