Buy me a coffee

Rename a text from URL

#1. Suppose you have a portfolio page with the URL like this:

  • /all-work/apple
  • /all-work/microsoft
  • /all-work/instagram

You want to change “all-work” to “top-10” so the URL will be

  • /top-10/apple
  • /top-10/microsoft
  • /top-10/instagram

#2. You can use this code to All Work Page Header Code Injection

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
$(document).ready(() => {
    const links = $('.grid-item')
    for (let i=0; i<links.length; i++) {
        const href = $(links[i]).attr('href')
        $(links[i]).attr('href', href.replace('all-work', 'top-10'))
    }
})
</script>