Jump to content

Replace Blog Post Pagination Links with "Show All"

Go to solution Solved by Lesum,

Recommended Posts

Hello,

I am using the blog feature to function as a directory list of schools on my website. Each blog post is an individual page for a school. I would like to replace the current next/last pagination links on the blog pages with a link back to the main blog. Is that possible? If so, would like the text to be left aligned on the page and say 'Show All Schools'. Thank you!

Blog URL: https://stingray-toucan-3sex.squarespace.com/register
PW: PYogi2024!!

PY SS.png

Link to comment
  • Replies 10
  • Views 821
  • Created
  • Last Reply

Top Posters In This Topic

3 hours ago, tuanphan said:

You mean

  • Remove both text
  • Add a text in middle with name: Show All Schools and link to directory list page?

Yes, sorry for any confusion. I'd like the text that says "Show All Schools" to be left aligned, but if centered on the page is the only option, I will take it!

Since I've posted this, I made the site live. You can see the registration page here: https://petiteyogi.com/register

Thank you!

Link to comment
On 8/14/2024 at 8:01 PM, socialstylate said:

Yes, sorry for any confusion. I'd like the text that says "Show All Schools" to be left aligned, but if centered on the page is the only option, I will take it!

Since I've posted this, I made the site live. You can see the registration page here: https://petiteyogi.com/register

Thank you!

How about right text? Remove left + right, then add Show All Schools on left side?

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
  • Solution
Posted (edited)

@socialstylate Hi! You can add this code to Website > Pages > Website Tools > Code Injection > Header to display the custom pagination "Show All Schools."

<script>
document.addEventListener('DOMContentLoaded', function() {
    const anchorTag = document.createElement('a');
    anchorTag.href = 'https://petiteyogi.com/register';
    anchorTag.textContent = 'Show All Schools';
    anchorTag.className = 'custom-pagination item-pagination-title';

    const iconDiv = document.createElement('div');
    iconDiv.className = 'item-pagination-icon icon icon--stroke';
    iconDiv.innerHTML = `
        <svg class="caret-right-icon--small" viewBox="0 0 9 16">
            <polyline fill="none" stroke-miterlimit="10" points="1.6,1.2 6.5,7.9 1.6,14.7"></polyline>
        </svg>
    `;

    anchorTag.prepend(iconDiv);

    const itemPagination = document.getElementById('itemPagination');

    if (itemPagination) {
        itemPagination.appendChild(anchorTag);
    }
});
</script>

<style>
.item-pagination-link--prev, .item-pagination-link--next {
    display: none !important;
} 

a.custom-pagination.item-pagination-title {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
    align-content: center;
    gap: 15px;
}

.custom-pagination .icon, .custom-pagination svg {
    width: 18px !important;
    height: 32px !important;
    transform: rotate(90deg);
} 

#itemPagination {
    display: flex;
    justify-content: flex-start;
}
</style>

Let me know how it goes. Thanks! 

Edited by Lesum
Updated code: left-arrow-icon

If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. 

Sam
Web Developer & Digital Designer

 Did you find my contribution helpful? Buy me a coffee?

Link to comment
22 hours ago, Lesum said:

@socialstylate Hi! You can add this code to Website > Pages > Website Tools > Code Injection > Header to display the custom pagination "Show All Schools."

<script>
document.addEventListener('DOMContentLoaded', function() {
    const anchorTag = document.createElement('a');
    anchorTag.href = 'https://petiteyogi.com/register';
    anchorTag.textContent = 'Show All Schools';
    anchorTag.className = 'custom-pagination item-pagination-title';

    const iconDiv = document.createElement('div');
    iconDiv.className = 'item-pagination-icon icon icon--stroke';
    iconDiv.innerHTML = `
        <svg class="caret-right-icon--small" viewBox="0 0 9 16">
            <polyline fill="none" stroke-miterlimit="10" points="1.6,1.2 6.5,7.9 1.6,14.7"></polyline>
        </svg>
    `;

    anchorTag.prepend(iconDiv);

    const itemPagination = document.getElementById('itemPagination');

    if (itemPagination) {
        itemPagination.appendChild(anchorTag);
    }
});
</script>

<style>
.item-pagination-link--prev, .item-pagination-link--next {
    display: none !important;
} 

a.custom-pagination.item-pagination-title {
    display: flex;
    flex-direction: row-reverse;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
    align-content: center;
    gap: 15px;
}

.custom-pagination .icon, .custom-pagination svg {
    width: 18px !important;
    height: 32px !important;
} 

#itemPagination {
    display: flex;
    justify-content: flex-start;
}
</style>

Let me know how it goes. Thanks! 

This looks great! Thanks so much for providing the code. One other request. Is there a way to update the code so that the caret/arrow is to the left of the "Show All Schools" text and is pointing left?

Link to comment
14 hours ago, Lesum said:

@socialstylate The updated code isn't appearing on your site from my end; it’s still showing the previous code I shared. Please try adding the entire code again.

I accidentally copied the code from when I quoted you - sorry about that. Thank you so much - the code works and it looks great!

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.