Support » Themes and Templates » If the_title() echo into a HTML class

  • Resolved Bennyjh

    (@bennyjh)


    Can’t get this to work for some reason;

    <li><a href="#" class"<?php if (the_title()=='Home' { echo 'current-page'; } ?>">Home</a></li>

    Should I be using a different wordpress function? Any help would be appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • esmi

    (@esmi)

    Forum Moderator

    Assuming that this is within the Loop, try:

    <li><a href="#" class"<?php if (get_the_title()=='Home' { echo 'current-page'; } ?>">Home</a></li>

    Thanks for the help, but I managed to get it working.

    For anyone interested;

    <li><a href="#" <?php if(is_page('Home')){ echo 'class="current-page" style="color:#FFF"'; } ?>>Home</a></li>

    You can also use is_front_page()

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘If the_title() echo into a HTML class’ is closed to new replies.