0

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 3

1

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> 
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, I've edited the code <li><a <?php if( get_the_archive_title() == "1 Bedroom House Plan") { echo 'class="active-tag"'; } ?> href="#">1</a></li> but still not showing the css class
0

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>

1 Comment

after editing the code to <li><a <?php if( get_the_archive_title() == "1 Bedroom House Plan") { echo 'class="active-tag"'; } ?> href="#">1</a></li> still not showing the css class
0

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 :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.