Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Detect what page in WordPress

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #161039
    justdan
    Participant

    Hey guys. I’m working on a little theme and I’ve hit a road block. It’s local so I can’t give a codepen link so I’ll try to explain this the best I can. My home page loads up and I have everything looking normal. When I click to go to a new page though I need the navigation to change to different navigation style. I need some way to know what page I am on so I can know which navigation to load. I imagine there is some type of way I can use an if/else statement with PHP to achieve this but I’m a bit stuck. I’ll include an idea I had though in the snippet below. Sorry if this comes off as a two part question. Any help is always greatly appreciated.

    <?php if ( header('Location:'.get_site_url()){

    } else {

    } ?>

    #161041
    Alen
    Participant
    if ( is_page('slug') ) {
      // do something
    }
    

    slug is the name of the page. So if you create a page called About Me and the url looks like this domain.com/about-me your slug is ‘about-me`…

    So the code would be

    if ( is_page('about-me') ) {
      // do something
    }
    

    http://codex.wordpress.org/Conditional_Tags

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.