Clicky

  1. Home
  2. How To
  3. How to change Post title tag

How to change Post title tag

If you want to change the Post title tag then first you need to create a Custom Plugin and add below the filter.

Example code:

add_filter('ampforwp_modify_title_tag','prefix_amp_title'); 
function prefix_amp_title($title){ 
$title = '<h2 class="amp-post-title">' . wp_kses_data( get_the_title(ampforwp_get_the_ID()) ) . '</h2>'; 
return $title; 
}

The Output of Post title tag in AMP

That’s it for this tutorial!

We hope it helped you. If you have any feedback or questions, then please share them in the comments section below.

Ask your Questions Directly!
If you can't find the solutions in this article, then just ask us in the comments and we will answer it for you!
Updated on May 8, 2020

    Are you still looking for a solution?

    Then fill out the below form and we will reach out to you within a few hours.


    Was this article helpful?

    Related Articles

    Comments

    1. Does this hook still exist? cause it dosent work form me. thanks

    2. Hi,

      This is very strange, I installed AMP on a staging site and a live site but for some reason the staging site title tag is correctly reading the tag but my live site for some reason picks . Any idea how this is possible? Is there a file I can access to check the default AMP tag?

    Leave a Comment