• My website uses both pixelpost and wordpress. https://www.reformstudios.com/pmac/home.html

    The menu is CSS controlled background images. When you are on a particular page, I want the menu item to remain highlighted. The problem is that I need to access the_ID() from within the header.php to set the correct body ID to tell the css what page I’m on.

    The code to control the body tag would be something like this…

    <body id="<?php
    	if (the_ID() == 3) { echo "biography";}
    if (the_ID() == 4) { echo "contact";}
    if (the_ID() == 5) { echo "reel";}
     ?> ">

    and my menu CSS is :

    #news #c-nav #cn-news a,
    #gallery #c-nav #cn-gallery a,
    #gallery-image #c-nav #cn-gallery a,
    #biography #c-nav #cn-bio a,
    #reel #c-nav #cn-reel a,
    #contact #c-nav #cn-contact a {
    	background-position: 0 -47px !important;
    	}

    How do I access the page ID from within the header?

    Many thanks for your advice!

  • The topic ‘How to access the_ID() from the header.php’ is closed to new replies.