Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #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 ago by THP Studio.
    • This topic was modified 2 years ago by THP Studio.
    #1373260

    Hey 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ünter

    #1373284

    Hey 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

    #1373338

    but 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.

    #1373396

    Hi,


    @Guenni007

    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ünter

    #1373401

    True, 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 ago by Guenni007.
    #1373405

    Thanks for working on this Gunter and for your input too Guenni007!

    #1376225

    Just tested with the 5.3 release and works great so far, thanks again for implementing this.

    Can close this thread.

    #1376242

    Hi,

    Thanks for bring it up, Tim! :)

    Best regards,
    Yigit

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Remove self from displaying in masonry/portfolio elements’ is closed to new replies.