Switching single post title h1 with h2

Community Forums Forums Design Tips and Tricks Switching single post title h1 with h2

This topic is: resolved

This topic contains 3 replies, has 2 voices, and was last updated by  David Chu 1 year, 5 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #32732

    matt@mattdotcom.com
    Participant
    Post count: 10

    Hi All,

    Due to color formatting in a design I’m constructing, I need the post title of single posts to display as <h2> instead of <h1>

    I’m close, with this added to functions.php -

    add_action(‘genesis_post_title’, ‘h2_title’);
    function h2_title() {
    if ( is_single ( ) ) {
    remove_action(‘genesis_post_title’, ‘genesis_do_post_title’);
    the_title( ‘<h2>’, ‘</h2>’);
    }
    }

    BUT it’s still displaying the original <h1> title in addition to the <h2> title.

    Site is here on lockdown:  http://www.jonathanmerker.com/kind/
    username: guest
    password: WPguest

    Any help appreciated!

    Matt

    #32954

    David Chu
    Participant
    Post count: 1355

    Rather than removing the title, you can filter it. Check this out, you’ll be able to adapt it to what you’re doing.

    Still, from an SEO perspective, generally you want that nice juicy H1 tag. Rather than doing the above, I would just style the H1 tag to be like your H2 tag. Cleaner. I have one client who has me playing with title styling constantly. The only tricky thing is to make sure the different types of titles are kept straight, which requires some CSS skills.

    Dave


    Dave Chu · Custom WordPress Developer – likes collaborating with Designers

    #32957

    matt@mattdotcom.com
    Participant
    Post count: 10

    That did the trick!  thank you!

    For anyone referring back to this post, here’s how I tweaked it:

     
    /** make single post titles H2 instead of H1 **/

    add_filter( ‘genesis_post_title_output’, ‘ac_post_title_output’, 15 );
    function ac_post_title_output( $title ) {
    if ( is_single () )
    $title = sprintf( ‘<h2 class=”entry-title”><span>%s</span></h2>’, apply_filters( ‘genesis_post_title_text’, get_the_title() ) );
    return $title;
    }

    #32970

    David Chu
    Participant
    Post count: 1355

    Coolness!


    Dave Chu · Custom WordPress Developer – likes collaborating with Designers

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.