-
AuthorPosts
-
November 17, 2022 at 11:52 pm #1373024
Hey Gunter,
So we are often using portfolio elements such as the Masonry element to pull in portfolio items to a page – or sometimes to pull them onto a portfolio page.
For example:
We have a portfolio post called “Car 1”
Then on the Car 1 post we have a bunch of content, and then at the bottom we might use another Masonry element to pull in all other cars for a Related Items section.
However, the issue we have is that Car 1 can be pulled in as a related item, even though you’re already on the Car 1 page.
Can we get some logic added that does a check to prevent displaying itself if the element is used on a portfolio page (or custom post type)? Perhaps a simple checkbox could be added in the backend for something like “Use as a related item section?” that would turn this ability on/off?
Please see content below for an example of what I’m talking about
Thanks a lot
Tim
- This topic was modified 2 years, 1 month ago by THP Studio.
- This topic was modified 2 years, 1 month ago by THP Studio.
November 20, 2022 at 1:17 pm #1373260Hey Tim,
Thank you for this input. Makes sense.
I added to our dev repo and will check if there is an easy way to implement this. I will keep you informed here – or check the changelog.
Best regards,
GünterNovember 20, 2022 at 5:38 pm #1373284Hey Gunter,
Thanks for looking into it, I was thinking it might just be a simple 1 or 2 lines of code to check postID’s or something, but you’re the expert, I’ll leave it with you.
Would be a very helpful improvement though if it can be added.
Will keep an eye on the changeling as I always do. 5.3 looks interesting!
Tim
November 21, 2022 at 11:08 am #1373338but wouldn’t this solve your problem:
( use it in your child-theme functions.php )function ava_exclude_current_post($query) { if (is_singular('post') || is_singular('portfolio') ) { $exclude = avia_get_the_ID(); $query->set( 'post__not_in', array($exclude) ); } } add_action('pre_get_posts', 'ava_exclude_current_post');
I think it is generally pointless to include the current post in a listing that appears on the same page.
In my opinion, this could also readily become the default behaviour – without a checkbox.November 21, 2022 at 4:48 pm #1373396Hi,
Your solution will not work in masonry entries with load more button and when the entry is queried with the load more by ajax.
I’ve already a solution for that.For backwards compatibility I think we must have an option to activate it.
And I will check other ALB elements to add it.
Best regards,
GünterNovember 21, 2022 at 5:21 pm #1373401True, I didn’t think of the load more button – and it’s probably similar with pagination.
Edit : tested pagination – that will work – but looks strange ( as if i reload the page )
- This reply was modified 2 years, 1 month ago by Guenni007.
November 21, 2022 at 5:37 pm #1373405Thanks for working on this Gunter and for your input too Guenni007!
December 14, 2022 at 10:07 pm #1376225Just tested with the 5.3 release and works great so far, thanks again for implementing this.
Can close this thread.
December 14, 2022 at 11:21 pm #1376242 -
AuthorPosts
- The topic ‘Remove self from displaying in masonry/portfolio elements’ is closed to new replies.