skip to Main Content

I’m having a problem with why this code is not working.

<li><?php if( get_the_archive_title() == "1 Bedroom House Plan") { echo 'class="active-tag"'; } ?><a  href="#">1</a></li> 

All I want is if the archive page title is equal to the string on the right to echo the CSS class of "active-tag", I’m using WordPress here!

Thanks again 🙂

3

Answers


  1. Chosen as BEST ANSWER

    Few changes and it worked,

    <li><a <?php if( single_cat_title( '', false ) == "1 Bedroom House Plan") { echo 'class="active-tag"'; } ?> href="#">1</a></li>

    Cheers all :)


  2. Try to add like below:

    <li <?php if( get_the_archive_title() == "1 Bedroom House Plan") { echo 'class="active-tag"'; } ?>><a  href="#">1</a></li>
    
    Login or Signup to reply.
  3. you just misplaced your php code :

    <li> <?php if( get_the_archive_title() == "1 Bedroom House Plan") { echo 'class="active-tag"'; } ?>  <a  href="#">1</a></li> 
    

    to

    <li <?php if( get_the_archive_title() == "1 Bedroom House Plan") { echo 'class="active-tag"'; } ?>  
     >
        <a  href="#">1</a>
    </li> 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search