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 6 years, 7 months ago.
- AuthorPosts
- February 8, 2017 at 9:40 pm #11860
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]
February 10, 2017 at 2:07 am #11877hi 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!
February 10, 2017 at 10:24 am #11879Hi,
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 :)
February 10, 2017 at 5:44 pm #11890hmmm 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!
sFebruary 13, 2017 at 5:16 pm #11923hi,
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’),
);February 16, 2017 at 10:55 am #11971Hi,
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.
Best,
Let’s hope this works 🙂
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.