Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Change Titles on Blog Category Pages


Question

Site URL: https://www.bycourtneytodd.com/

Hi! Can someone help me figure out how to have different titles or headers at the top of my linked category pages? I've sorted my blog posts into categories and have linked buttons to a particular category but when I go to the category pages they all say "On The Blog" at the top and I want them to be titled based on the category.

I know I can create a page and add text box then a summary blog underneath, but not all my blog categories will have their own page so I'm hoping to find a work around to have each blog category link to a page with a title of the same name (e.g. when someone clicks on the blog category "recipe" the linked page should say "recipe" at the top, and when they click "Canadian Travels" the linked page should say "Canadian Travels" at the top, etc.)

Any help is very appreciated!

 

 

Screen Shot 2021-04-05 at 8.13.42 PM.png

Link to comment

7 answers to this question

Recommended Posts

  • 0

Add t

On 4/6/2021 at 7:19 AM, thenookcreative said:

Site URL: https://www.bycourtneytodd.com/

Hi! Can someone help me figure out how to have different titles or headers at the top of my linked category pages? I've sorted my blog posts into categories and have linked buttons to a particular category but when I go to the category pages they all say "On The Blog" at the top and I want them to be titled based on the category.

I know I can create a page and add text box then a summary blog underneath, but not all my blog categories will have their own page so I'm hoping to find a work around to have each blog category link to a page with a title of the same name (e.g. when someone clicks on the blog category "recipe" the linked page should say "recipe" at the top, and when they click "Canadian Travels" the linked page should say "Canadian Travels" at the top, etc.)

Any help is very appreciated!

Add this to Settings > Advanced > Code Injection > Header. Do similar for other category pages

<script>
  if (window.location.pathname == "/blog/category/Canada+Travels") {
    document.querySelector('body').classList.add('canada-travels');
  }
</script>
<style>
  .canada-travels section.Intro h2 {
    visibility: hidden;
}
  .canada-travels section.Intro h2:before {
    content: "Canada Travels Blog";
    visibility: visible;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}
</style>
  

image.thumb.png.f18015060577b06ede2d0dd75b25e8fc.png

Edited by tuanphan
typo
Link to comment
  • 0
On 4/13/2021 at 7:48 AM, thenookcreative said:

Thank you for your help! I added the code like you said but nothing changed.

can you keep the code in Code Injection? We can check easier

image.thumb.png.0ac950d1f9597f8e29e8f2d897eb4450.png

Link to comment
  • 0

Replace the scrript tag with the following.

<script>

  window.addEventListener ( 'DOMContentLoaded', ( ) => {
  
    if ( location.pathname == '/blog/category/Canada+Travels' ) {
    
      document.querySelector ( 'body' ).classList.add ( 'canada-travels' );
      
      }
      
    } );
    
  </script>

Let us know how it goes.

Find my contributions useful? Please like, upvote, mark my answer as best , and see my profile. Thanks for your support!

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...