Forums

exclusion categories in get_adjacent_post just NOT WORKING in WP 2.5 (13 posts)

  1. corpodibacco
    Member
    Posted 3 months ago #

    get_adjacent_post is the function WP now uses to have previous_post_link and such functions working.

    Anyway the ability to exclude a category when spewing the link is broken for me.

    To reproduce this problem just try having previous_post_link exclude one of the categories, like such:

    previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '2')
    (or whatever category you want to exclude: it will be simply ignored.)

    The culprit is get_adjacent_post, but i find it totally complicated now so I just couldn't fix it.

    Any ideas?

  2. filosofo
    Member
    Posted 3 months ago #

    When you pass arguments to a function like previous_post_link, you need to leave out the variable names. For example, the line you have above should be
    previous_post_link('« %link', '%title', false, '2')

  3. corpodibacco
    Member
    Posted 3 months ago #

    filosofo, I know. That was just sloppy copy and paste from the function, my bad.
    I am actually a plugin developer so I know a little php.
    Don't just assume it is a mistype or some basic misunderstanding we are talking about here.
    Have you tried the function? Have you found the exclusion of categories working?

  4. corpodibacco
    Member
    Posted 3 months ago #

    so anybody has any idea? basically next/previous post link are not capable to exclude categories, that's the gist in case you missed it...

  5. TylerMartin
    Member
    Posted 3 months ago #

    Yeah, I've had the same problem and it's really annoying.

    A theme I've developed works great in 2.3, not in 2.5. The excluded_categories parameter is totally broken and I can't seem to find any real acknowledgement of it. I had posted over in the themes section, I'm surprised more theme writers have not come across this, it's one of only 4 parameters of the main navigation system of WordPress.

    It would seem a shame to have to write separate navigation functions just for a theme because the built in ones stopped working the way they were intended.

  6. TylerMartin
    Member
    Posted 3 months ago #

    Just saw this...

    http://trac.wordpress.org/ticket/6528

    I hope it's not until 2.6 that this is fixed.

  7. filosofo
    Member
    Posted 3 months ago #

    Whoops, I didn't see #6528, but I just posted a patch to http://trac.wordpress.org/ticket/6551

  8. Monika
    Member
    Posted 3 months ago #

    @ filosofo

    thanks a lot ;) you made my day,

    this days and so much days in the past...

    regards Monika

  9. TylerMartin
    Member
    Posted 3 months ago #

    Yes, much thanks Filosofo, you're my hero for the day as well.

  10. taote
    Member
    Posted 3 months ago #

    Wow, thank you Filosofo!

  11. TylerMartin
    Member
    Posted 3 months ago #

    One problem with 6551/fix_get_adjacent_post.diff

    Even with that fix, WP 2.5 doesn't behave quite the same as previous WordPress versions.

    If your excluded category is "dog", it will skip navigating to a post who's category is "dog". However, if the post has more than one category, like "dog" and "cat", then it will not skip that post. So it is counting the post as not being in the "dog" category simply by having a category assigned to it besides "dog".

  12. taote
    Member
    Posted 2 months ago #

    Yes, it doesn´t work properly. Have you find any solution TylerMartin?

  13. TylerMartin
    Member
    Posted 2 months ago #

    No sorry. And the ticket got closed. I reopened it so maybe someone can track down the remaining problem.

Reply

You must log in to post.

About this Topic