Jump to content

Summary Block Exclude Current Blog Post

Recommended Posts

  • 1 year later...

Try adding this to Code Injection > Footer

<script>
  window.addEventListener('load', function () {
    function removeMatchingPageFromRelatedPosts() {
      var currentPath = window.location.pathname;

      var matchingSummaryItem = document.querySelector(
        `[href="${currentPath}"]`
      );

      if (!matchingSummaryItem) return;

      var summaryParent = matchingSummaryItem.closest('.summary-item');

      summaryParent.remove();
      console.log('matching blog post removed');

      window.Squarespace.initializeLayoutBlocks(Y);
    }

    removeMatchingPageFromRelatedPosts();
  });
</script>

Code by @RyanDejaegher

Quote

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
  • 1 year later...
On 9/17/2023 at 10:53 PM, pro said:

@tuanphan @RyanDejaegher

Do you guys know a code that would work for store products by any chance?

I need to exclude the current product from a summary block.

Can you share link to page where you use summary block?

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
On 9/19/2023 at 7:22 PM, pro said:

Use this code to CSS box

.ProductItem .ProductItem-additional .summary-item:first-child {
    display: none;
}
.ProductItem .ProductItem-additional .summary-item {
    clear: none !important;
}

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
14 hours ago, tuanphan said:

Use this code to CSS box

.ProductItem .ProductItem-additional .summary-item:first-child {
    display: none;
}
.ProductItem .ProductItem-additional .summary-item {
    clear: none !important;
}

 

 

Hi Tuan, unfortunately, this code only works if the excluded item is first-child. But it's not always the case in my store. Sometimes the excluded item is first, other times it's 2nd, or 3rd, or last. Is there a JS code that would automatically exclude the current product no matter its position in the summary block?

The JS code you quoted earlier in the thread works perfectly for blog posts, but not for store products.

Link to comment
On 9/22/2023 at 7:08 AM, pro said:

 

Hi Tuan, unfortunately, this code only works if the excluded item is first-child. But it's not always the case in my store. Sometimes the excluded item is first, other times it's 2nd, or 3rd, or last. Is there a JS code that would automatically exclude the current product no matter its position in the summary block?

The JS code you quoted earlier in the thread works perfectly for blog posts, but not for store products.

I have no ideal, you try contacting RyanDejaegher

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.