remove current post from sidebar widgets

Posted in: Newspaper
Post count: 5

Hello,

I would like to remove the current post from the sidebar widgets for a single post type.
Can you tell me what is the code for doing this?

Thank you,
Ancuta Ciubotaru

Post count: 5

i will add an example. you can look at this post: https://cherish-humanity.org/razboiul-comunistilor-impotriva-familiei-partea-ii-feminismul-bolsevic/

In “ULTIMELE ARTICOLE” sidebar the current article is also shown. I don’t want it to be shown. I use tagdiv 8 to display this sidebar.

usually I would use this code for the wordpress recent posts widget, but I don’t know what action you have for this theme.

function be_exclude_current_post( $args ) {
if( is_singular() && !isset( $args[‘post__in’] ) )
$args[‘post__not_in’] = array( 1482 );
return $args;
}
add_filter( ‘widget_posts_args’, ‘be_exclude_current_post’);

Post count: 5

And I am interested to do this for category pages. Example here:
https://cherish-humanity.org/category/comunismul-un-concept-anti-umanitate/psihologie-caracteristicile-comunismului/

I want to take out from the right sidebar, the articles that are already displayed on the left side of the page.

Post count: 18283

Hello !

On your page everything that is inside the sidebar comes from Appearance – Widgets. You can use Single post templates from the cloud library to have a customizable sidebar: https://forum.tagdiv.com/design-post-pages-using-cloud-library-templates/ and for category page you have this: https://forum.tagdiv.com/cloud-library-category-templates/

Thank you !

Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.