Jump to content

Don't show current blog post in summary block

Recommended Posts

Posted

Site URL: https://tomato-hibiscus-5kcf.squarespace.com/stories/born-to-lead

Hello! I would like to include a summary block on my blog posts that links to "Related Stories"  I can't seem to find a way to remove the current blog post from the summary  block. I've tried some codes that I've found here, changing categories around etc, but none have worked for me. There are hundreds of stories and blog posts to transfer over so it would be very helpful if it was site-wide. Why this isn't an option from Squarespace, I don't know...Can anyone help me out? @tuanphan

https://tomato-hibiscus-5kcf.squarespace.com/stories/born-to-lead

password: Magnolia

Posted (edited)

This has come up before and so far there is no one who has come up with a great way to hide the current blog post in a summary block, that may be due to the fact that when chosen it navigates away from the page the block is on, unlike an index page which keeps the thumbnails at the bottom of the same page where the index item takes you. As a matter of fact Avenue, the template that I use, has the hide active item as an option by default.  

This code has been tried by some, but it didn't have a lot of accolades. It might work for you.  It goes into custom css. 

.collection-type-blog.view-item .summary-item-list .sqs-active-slide {
    display: none;
}

 

Edited by derricksrandomviews
  • 3 weeks later...
  • 2 months later...
  • 1 year later...
  • 4 months later...
Posted

@RyanDejaegher Thanks so much for this code above...

 

it works for me on individual blog posts but not on the home page of my site. (www.readalmostfamous.com)

 

could you help with this please?

 

best wishes 

  • 2 weeks later...
Posted
On 5/21/2023 at 5:15 AM, jake98 said:

@RyanDejaegher Thanks so much for this code above...

 

it works for me on individual blog posts but not on the home page of my site. (www.readalmostfamous.com)

 

could you help with this please?

 

best wishes 

With homepage, try adding this to Design > Custom CSS

div#block-yui_3_17_2_1_1683917161417_33080 .summary-item:first-child {
    display: none;
}

 

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

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Posted

@tuanphan it didnt work - please look at site for reference. i would also need this to work all the way down the site as each section would be similar layout 

thanks as always!

Posted
On 6/1/2023 at 8:41 PM, jake98 said:

@tuanphan it didnt work - please look at site for reference. i would also need this to work all the way down the site as each section would be similar layout 

thanks as always!

That code will remove First Item from Summary in Music News section

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

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Posted

is it possible to get code to do this for all the sections on the homepage? i dont plan to add anymore sections to the homepage.

also, it removes it, but it doest push up another article it just shows a blank space.

 

thanks as always for your help!

  • 1 year later...
Posted

Thank you @RyanDejaegher this worked perfectly on the blog pages where I have summary blocks. The only thing I noticed is that removing the current blog post from the summary block creates an empty space, is the code changeable to pull another item from the blog instead of the one that's hidden? Thanks a million! ✌🏽

  • 3 months later...
Posted

I've tweaked @RyanDejaegher's code to avoid the empty space issue.  First add the following to your code:

<script>
    window.addEventListener('load', function () {
      function removeMatchingPageFromRelatedPosts() {
        var currentPath = window.location.pathname;
  
        var matchingSummaryItem = document.querySelector(
          `[href="${currentPath}"]`
        );
  
        if (!matchingSummaryItem) {
            console.log('cant find matching blogpost, removing last instead')
            matchingSummaryItem = document.querySelector(
              'div.summary-item:last-of-type'
            );

        }
  
        if (!matchingSummaryItem) return;

        var summaryParent = matchingSummaryItem.closest('.summary-item');
  
        summaryParent.remove();
        console.log('matching blog post removed');
  
        window.Squarespace.initializeLayoutBlocks(Y);
      }
  
      removeMatchingPageFromRelatedPosts();
    });
  </script>

Now update your Summary block to display one more item than you want, e.g. if you want to show 4 items, configure 5 to be retrieved.  This code will either remove the matching post, or the last one in the list.

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.