Ready to get started?Download WordPress


Yet Another Related Posts Plugin (YARPP)
[resolved] [Plugin: Yet Another Related Posts Plugin] exclude not work in related_posts (6 posts)

  1. ciberwolf
    Posted 2 years ago #

    With the new updates to the Exclude stopped working in related_posts function.

    In previous versions worked like this:

    related_posts (array ('exclude' => array ('category' => 1,2,3,4,5)));

    Now in this version according to what I read to do this:

    related_posts (array ('exclude' => array (1,2,3,4,5)));

    Not that I'm doing wrong, I need to use 2 times related_posts function in single.php and using it 2 times is showing me these related posts

    related_posts (array ('exclude' => array (1,2,3,4)));
    related_posts (array ('exclude' => array (5)));


  2. mitcho (Michael Yoshitaka Erlewine)
    Plugin Author

    Posted 2 years ago #

    Sorry you're having trouble with this. I think you understood the instructions in the readme correctly.

    So, you're saying the code related_posts (array ('exclude' => array (1,2,3,4,5))); isn't working? You have to make sure the numbers in exclude there are term_taxonomy_ids, not term_ids. Is that what you've done?

  3. chrisjb
    Posted 2 years ago #

    Hi mitcho,

    I'm using the PHP method in this way:

    related_posts (array ('exclude' => array (285,514)));

    (same as above)

    I have found the category IDs by hovering over the categories in WP-Admin Categories admin page and viewing the link that displays in the bottom left of my browser. Do you know if those are the term_taxonomy_ids?

    It still does not seem to exclude those categories. I've also tried the Pool options in WP-admin and that doesn't seem to work when I use the PHP method.

    Do you have any idea what I might be doing wrong?

    Thanks in advance and really great plugin by the way.

  4. mitcho (Michael Yoshitaka Erlewine)
    Plugin Author

    Posted 2 years ago #

    I think the category IDs that are displayed in the link are *not* the term_taxonomy_ids required. If you have access to your MySQL database, that would be the most direct way of identifying the term_taxonomy_ids of relevant categories.

  5. chrisjb
    Posted 2 years ago #

    Ah OK great thanks mitcho. I'll have a look at the MySQL as I can access that. I will post an update once I have got it working correctly.

  6. Matt Brett
    Posted 2 years ago #

    Just confirming that indeed, the category ID is not what's needed to exclude categories. I had to dig into the database to find out what term_taxonomy_id is associated with the categories I wanted to exclude.

    For others that might be trying to figure this out, here's how you find the term_taxonomy_id for a category...

    1. Find the ID of the category you want to exclude by going to Posts -> Categories in WP-Admin, and hovering over the category's name in the list. Look down at the status bar in your browser and note the tag_ID.
    2. You'll need to access your database somehow. Most servers have phpMyAdmin installed, and this is what I used. Browse the wp_term_taxonomy table and sort if by term_id.
    3. Find the ID of the category you're after. Look at the value in the term_taxonomy_id column - this is the value you need for the exclude parameter.

    Hope that helps clear things up.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic