Buy me a coffee

How to change blog posts titles all at once through some code?

Suppose all your blog posts have the same template title like this: “Name of the Book – Author: Author Name“.

And you need to remove the word “Author:” from all blog posts.

How To Change Blog Posts Titles All At Once Through Some Code 01 Min

You can follow these.

#1. Titles on Blog List + Blog Post Detail

Use this code to Code Injection > Footer

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
  $(document).ready(function(){
    $("h1.blog-title a, .blog-item-title h1").html(function() { 
          return $(this).html().replace("Author:", " ");  
    });
});
</script>

How To Change Blog Posts Titles All At Once Through Some Code 02 Min

Result:

How To Change Blog Posts Titles All At Once Through Some Code 03 Min

#2. Titles on Summary Block

Change #1 code to this new code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
  $(document).ready(function(){
    $("h1.blog-title a, .blog-item-title h1, a.summary-title-link").html(function() { 
          return $(this).html().replace("Author:", " ");  
    });
});
</script>

Result:

How To Change Blog Posts Titles All At Once Through Some Code 04 Min

#3. Titles on Pagination Text

How To Change Blog Posts Titles All At Once Through Some Code 05 Min

Use this new code for #1, #2 and #3.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
  $(document).ready(function(){
    $("h1.blog-title a, .blog-item-title h1, a.summary-title-link, h2.item-pagination-title").html(function() { 
          return $(this).html().replace("Author:", " ");  
    });
});
</script>

Result:

How To Change Blog Posts Titles All At Once Through Some Code 06 Min