• Resolved mcbethar

    (@mcbethar)


    Hi to all,

    I’m needing some help with this piece of code:

    <?php $heading_tag = ( is_home() || is_front_page() ) ? 'h1' : 'div'; ?>

    It tells to use a H1 tag (on the tittle) in front page and/ or home.
    I need to edit this same code, adding that it must use a H2 tag if posts.

    Thanks in advanced for your time, and sorry for my poor english.
    Sincerely,

    Mcbethar

Viewing 2 replies - 1 through 2 (of 2 total)
  • this should use a h2 on single post pages:

    <?php $heading_tag = ( is_home() || is_front_page() ) ? 'h1' : (( is_single() ) ? 'h2' : 'div'); ?>

    or you can write it conventional:

    <?php if( is_home() || is_front_page() ) : $heading_tag = 'h1';
    elseif( is_single() ) : $heading_tag = 'h2';
    else : $heading_tag = 'div';
    endif; ?>
    Thread Starter mcbethar

    (@mcbethar)

    Hey alchymyth,

    Thanks a lot for your fast and accurated response!

    It looks great. Either way I decided to just “clean” the code, in order to show H1 on title in all the pages, so that permalink keeps H2:

    <?php $heading_tag = 'h1'; ?>

    Lot of thanks again for your time 🙂

    Sincerely,

    Mcbethar

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Need some help with code’ is closed to new replies.