• Hi!

    Im using a simple if to determine if a tab should have the class active or not, just for looks. I had it working before i turned on pretty permalinks, but now it wont work properly.

    <a href="?page_id=52" class="<?php if ( $page_id == "52" ) { echo "active"; } else { echo ""; } ?>"><span class="subborder">
            	<span class="subbutton">
                	Foto
                </span><!-- /subbutton -->
            </span></a><!-- /subborder -->

    Since it nolonger can recognize the page id, it doesn’t give it the active class since the if isn’t fullfilled. So is there a way of making it recognize a string, like “$page_id == foto”? Or some other way to get it to understand when that page is active? I works on categories, but not pages :< Thanks in advance!

Viewing 1 replies (of 1 total)
  • Moderator cubecolour

    (@numeeja)

    Quick & dirty way of doing this by a different approach: If you only have a few links to do this with and attach a class to the <body> for each page as in the 2010 theme (look in the header.php for the code). Then assign the page id to each link so you can target them easily in the css

    eg to highlight the link by turning the link red:

    .page-id-50 a#page_id_50,
    .page-id-51 a#page_id_51,
    .page-id-52 a#page_id_52 {
            color: red;
    }

    The link for page 50 will only be red when you are on page 50 and similarly for 51 & 52.

Viewing 1 replies (of 1 total)

The topic ‘Pretty permalinks creating 'active' trouble :’ is closed to new replies.