shortcode variables – exclude term

Home Forums Product Support Forums Related Posts Pro for WordPress Support shortcode variables – exclude term

This topic contains 5 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 7 years, 1 month ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #11860
    sank
    sank
    Participant

    hi – need a shortcode variable to exclude terms per shortcode-call in WP.

    example:

    [wpdreams_rpp id=0 exclude=kod9]

    [wpdreams_rpp id=0 exclude=hawtin]

    [wpdreams_rpp id=0 exclude=dubstep]

    #11877
    sank
    sank
    Participant

    hi there,
    need an answer on this asap please – site is showing items that shouldn’t be there so need a way to remove them per-post, not a blanket “exclude”

    thanks!

    #11879
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    There is no such shortcode argument, so unfortunately that won’t work. A possible solution could be to make function on the ‘rpp_keywords’ filter, which is executed when the keywords are extracted.

    Please note that this is not part of the plugin code and qualifies as a customization request, so I cannot guarantee it will work properly in every case.

    I’ve tested the following code, use it in the functions.php file in your theme directory:

    The $exceptions array contains the [post_ID => exception keywords array] pairs, you can add as many as you want with as many keywords as you need.
    In the example this line:

     '1' => array('word1', 'word2'),

    excludes word1 and word2 when the post ID equals 1.

    Also, make sure to save the instane options to clear the related posts cache, or to disable cache temporarily while testing (on the Advanced Options panel).

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #11890
    sank
    sank
    Participant

    hmmm i see – yes it kind of works, but then removes any posts with that keyword.

    is there a way to set the new code to exclude certain posts by ID instead of keyword?
    example:

    $exceptions = array(
    // Example: ‘[post ID]’ => array(‘[post ID]’),
    ‘9798’ => array(‘281’),
    ‘10422’ => array(‘5467’),
    );

    so in essence i’m telling one post-type to exclude a certain page from the results…

    (what would be ideal is in the actual plugin when the RPP box appears on every page in the admin, there could be an option to “Exclude this Post from Results!” )

    I know this si all customization, if it requires more money i can pay…

    thanks!
    s

    #11923
    sank
    sank
    Participant

    hi,
    is there a way to set the new code to exclude certain posts by ID instead of keyword?
    example:

    $exceptions = array(
    // Example: ‘[post ID]’ => array(‘[post ID]’),
    ‘9798’ => array(‘281’),
    ‘10422’ => array(‘5467’),
    );

    #11971
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Well, without making a direct change to the plugin files it’s not possible. I will try to detail a possible change for you.

    1. You will have to add an extra line to one of the core plugin files. I will make sure to add this line to the next release as well, so an update won’t break it. Open up the wp-content\plugins\related-posts-pro\includes\related_content.class.php file and scroll to line 82, which should be this:

    $args = wp_parse_args($args, $default_args);

    2. Just under that line, place this:

    $args = apply_filters('rpp_args', $args);

    3. Then instead of the code I suggested earlier, use this one to exclude by IDs:

    The only difference that in this case the IDs are simply listed as a string, not an array.
    Let’s hope this works 🙂

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 6 posts - 1 through 6 (of 6 total)

The forum ‘Related Posts Pro for WordPress Support’ is closed to new topics and replies.