Support » Fixing WordPress » PHP to change Page Title to default to H1 instead of H1

  • My WordPress theme has the Page Titles defaulting to H2. The way my theme and WP Bakery Page Builder (fka Visual Builder or Composer)are set up leaves me with no way to change that. The result is that none of my pages have H1 tags. 🙁

    I’m running a child theme and have a functions.php. The CSS Class for the page titles is “agni-slide-title”, if there’s a way I can override this with a CSS ID? I don’t think so though.

    I searched through 20 PHP files and finally found a reference to h2 in a theme-functions.php file in another folder. Here’s the original reference:

    // Filters of Agni Slider H tags
    add_filter( 'agni_page_header_h_tag', 'fortun_agni_slider_h_tag', 999 );
    add_filter( 'agni_slider_h_tag', 'fortun_agni_slider_h_tag', 999 );
    function fortun_agni_slider_h_tag($args){
        return 'h2';

    After hours of Googling, I took that line, changed to “h1”, changed the function name and put it in my functions.php.
    Here’s what I added.

    add_filter( 'agni_page_header_h_tag', 'fortun_agni_slider_h_tag', 999 );
    add_filter( 'agni_slider_h_tag', 'fortun_agni_slider_h_tag', 999 );
    function my_title_tag(){
        return 'h1';

    Nothing changed though; all page titles are still h2.
    I am PHP illiterate and relatively new to web design… sorry! Any help I can get would be SO appreciated!!

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Steve Stern


    Support Team Volunteer

    You could try and do a strreplace to change h2 to h1.

    Thanks Steve!
    I’m too PHP illiterate to know how to take that suppress code and change it to a replace function… if that’s even the right way to word it!
    And it’s not actually the “page title” either; there’s a toggle to Use “Page Title” or “Custom Title” it’s a field that is filled-in in place of the actual “page title”.

    Moderator Steve Stern


    Support Team Volunteer

    I suggest you get in touch with your theme developer.

    Yeah, tried that, but apparently my “support” is expired and I don’t have the $30 to renew it right now.
    I just assumed there would be a simple line of code, like the one I tried, that would change the “agni_slider_h_tag” to H1, or some kind of workaround to switch a theme’s default h tags.

    It looks like the filter you mentioned above is for a slider element and not for post titles. I’m not familiar with the theme you’re using, but can you edit the theme files? I know it’s not usually advised but you could swap the h2 tags for h1 tags there, or create a child theme and overwrite the template.

    the_title should just print the post title onto the page without any HTML tags around it so doing that might end up nesting tags where they shouldn’t be so probably best to avoid that I think.

    Hey Daniel,
    That’s all correct. And yes, I am running a child theme and have a functions.php file in my child theme; that’s where I added that function mentioned above, trying to get it to override the H2 the theme’s PHP has set.

    My theme allows for the page header to be a slider or just a single custom slide (hero banner) with a custom title or the page title. Even if “page title” is selected though, it’s still under the CSS class .agni-slide-title.

    I changed the function name to my_title_tag just because that’s what the one example I saw used, and because when I tried re-using “fortun_agni_slider_h_tag” is said “this function is already referenced” or something. I only know CSS, I know NOTHING about PHP, so I hoped/assumed the function name was just whatever I wanted to call it, like a CSS class… but I guess I was wrong? :-\ LOL

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘PHP to change Page Title to default to H1 instead of H1’ is closed to new replies.