Exclude Current Post ID #33377
pixelloop
started this conversation in
Feature Request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Describe the Problem
In the Loop Grid, you have an include and exclude option.
In the exclude option you have a toggle for "Avoid Duplicates"
You should have a toggle for "Exclude current post ID".
Often I will use a Loop grid at the bottom of the single post template or a single template for a custom post type and I want to show 4 or 8 other posts but this often ends up showing the post they are already on.
Propose a Solution
Add a toggle button underneath Avoid Duplicates that gets the current page ID and removes that from the query.
Additional Context
Only solution is to use custom PHP snippet at the moment:
add_action('elementor/query/exclude_current_case_study', function( $query ) {
if ( is_singular('case_study') ) {
$query->set('post__not_in', [ get_the_ID() ]);
}
});
Then add the Query ID exclude_current_case_study to the Loop Grid.
It should be a basic setting like other page builders provide with an on/off toggle.
Agreement
All reactions