And I have it completed but need to know who to send it to.
Plugin Author
satrya
(@satrya)
You can add custom parameter to the rpwe_default_query_arguments filter. Just add exclude => get_the_ID() to the filter.
Not sufficient – on the homepage and archive pages there will be more than one ID in the main flow.
I actually needed to add two things – one mentioned above – the other was to lock the category to match those of the currently displayed post. Both of these where implemented as checkboxes in the form.
@akitendo: I need to apply the same, but my knowledge in coding is practically none. Do you have a recipe? Can it work if I add it to my child-theme?
@akitendo: This is much wanted!
Both things I’m looking for. How could I get the ‘hack’ or @satrya could it be possible to get this functions included in the next plugin update?
Tom
(@tomasz_b)
I am also hoping for this update (to exclude the currently displayed post or posts).
Tom
(@tomasz_b)
Where exactly should I add exclude => get_the_ID() to the filter?
Should it go somewhere to the below code?
add_filter( 'rpwe_default_query_arguments', 'your_custom_function' );
function your_custom_function( $args ) {
$args['posts_per_page'] = 10; // Changing the number of posts to show.
return $args;
}
And then that code to functions.php?
I tried Satrya’s suggestion but I don’t know how to apply it correctly, and it was breaking the widget instead. So I asked here:
http://stackoverflow.com/questions/27969574/exclude-current-post-from-recent-posts-widget
AkiTendo’s solution sounds better though, if he can provide the hack and we could add it in a child-theme?
Tom
(@tomasz_b)
@satrya: Why not add this option to the widget?
I have only basic coding knowledge and compared to other plugins I find the configuration of this plugin highly confusing.
Plugin Author
satrya
(@satrya)
Hi,
I’m sorry for late reply, I’m pretty busy to update this plugin but I’ll add this feature soon. For now, please try
add_filter( 'rpwe_default_query_arguments', 'your_custom_function' );
function your_custom_function( $args ) {
global $post;
$args['exclude'] = $post->ID;
return $args;
}
Thank you for dropping by.
I just tried your suggestion. The current post still shows in rpwe.
I have this in my child-theme functions.php:
add_filter( 'rpwe_default_query_arguments', 'rpwe_exclude_current_post' );
function rpwe_exclude_current_post( $args ) {
global $post;
$args['exclude'] = $post->ID;
return $args;
}
Am I missing something?
I found a similar situation in a site from a similar plugin an tried the solution suggested there. It worked here. I have no idea if it can affect the results in any other undesired way, but at least it doesn’t display the current post in rpwe.
Here’s what I applied:
add_filter( 'rpwe_default_query_arguments', 'rpwe_exclude_current_post' );
function rpwe_exclude_current_post( $args ) {
if( is_singular() && !isset( $args['post__in'] ) )
$args['post__not_in'] = array( get_the_ID() );
return $args;
}
taken from this location
Any feedback is very much appreciated, in case you try this or find a better solution.
Tom
(@tomasz_b)
@patternreplicas thank you very much for posting that last code. It worked for me too.
I have also added to the array the posts which I wanted to exclude and it worked: array( get_the_ID(),100,101 );
I hope that it will not break our web sites once the plugin gets updated. But it seems to be working fine.
Great that it is working for you too : )
About “breaking the websites when the plugin gets updated”, all you have to do is create a child-theme and add these changes there instead of in your theme’s folder. It was one of the first things I did, it’s very easy and everyone in any forum post seems to be sure it’s the best way for not having trouble when plugins, or the theme itself, updates.
http://codex.ww.wp.xz.cn/Child_Themes