momallo Posted May 21, 2021 Share Posted May 21, 2021 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 emalu 1 Link to comment
derricksrandomviews Posted May 21, 2021 Share Posted May 21, 2021 (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 May 21, 2021 by derricksrandomviews Link to comment
momallo Posted May 21, 2021 Author Share Posted May 21, 2021 Thank you @derricksrandomviews I've tried this one before and tried it again, but sadly it doesn't seem to work. I appreciate the help! Link to comment
ievavi Posted June 7, 2021 Share Posted June 7, 2021 Following your post as well! Otherwise, you can try the paid solution: https://www.sqspthemes.com/plugins/related-posts-plugin 🙂 Link to comment
Max_Sheridan Posted August 31, 2021 Share Posted August 31, 2021 @RyanDejaegher has figured this out and posted the javascript (freshly updated), which works like a charm. Here's a link to his site: https://ryandejaegher.com/remove-current-post-summary-block-squarespace/. This is a huge help. tuanphan 1 Max Sheridan Copywritermaxcopy.co Link to comment
emalu Posted January 13, 2023 Share Posted January 13, 2023 @Max_Sheridan that's terrific for 7.1 (!) Would love a workable solution for 7.0... Link to comment
jake98 Posted May 20, 2023 Share Posted May 20, 2023 @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 Link to comment
jake98 Posted May 29, 2023 Share Posted May 29, 2023 @RyanDejaegherhi mate, could you assist with the above? your help is very much appreciated! Link to comment
tuanphan Posted June 1, 2023 Share Posted June 1, 2023 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!) Link to comment
jake98 Posted June 1, 2023 Share Posted June 1, 2023 @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! Link to comment
tuanphan Posted June 2, 2023 Share Posted June 2, 2023 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!) Link to comment
jake98 Posted June 5, 2023 Share Posted June 5, 2023 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! Link to comment
noblestudio Posted June 13 Share Posted June 13 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! ✌🏽 Link to comment
desg Posted September 30 Share Posted September 30 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. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment