WordPress.org

Ready to get started?Download WordPress

Forums

Yet Another Related Posts Plugin (YARPP)
[resolved] Possible to filter results based on post category (4 posts)

  1. dannoll
    Member
    Posted 3 years ago #

    I'd like to create a YARPP template that restricts/filters the results so that only posts in the same category as the current post are returned. (Note: I'd like to continue to use the other relatedness options like tags and body set in the admin panel.)

    Is this possible? And if so, how?

  2. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 3 years ago #

    Unfortunately there's no good way right now to get information on what post is actually being displayed (and thus what the category you want to target is) from within the YARPP template.

    If you call related_posts() yourself, you could do something tricky like storing what category you want to target, based on the current post, in a global variable before you call related_posts(), then reference that global variable in the YARPP template.

  3. dannoll
    Member
    Posted 3 years ago #

    Mitcho, thanks for the response. Sounds doable, particularly since I'll be calling related_posts() myself in most cases.

  4. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 3 years ago #

    Great!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic