Support » Fixing WordPress » Get Page_ID while using Permalinks

  • Resolved cyph1

    (@cyph1)


    hey there,

    Is it possible to get the page_id when permalinks are turned on?

    I am using an image based navigation and via php I always show another image depending on the active link:

    <?php
    switch ($_GET['page_id']) {
    case "9":
    	echo '<img src="images/about2.png">' ;
    break;
    default:
    	echo '<img src="images/about.png">' ;
    break;
    }
    ?>

    but when i am using permalinks this method is not longer possible..

    is there a way to get the page_it although permalinks are turned on??

    hope you can help me..

    regards from germany, cyph

Viewing 2 replies - 1 through 2 (of 2 total)
  • try this:

    <?php

    if ( is_page(9) ) {
    echo ‘<img src=”images/about2.png”>’ ;
    } else{
    echo ‘<img src=”images/about.png”>’ ;
    }

    ?>

    instead of is_page(9) you can also say is_page(‘about2’) where about2 is the page slug of the page. or is_page(‘About 2’) where ‘About 2’ is the title of the post

    woooow awesome.. big big thx dude 🙂

    i use the third method with is_page(‘About 2’).. it works fine.. you should only watch about the img sources ..

    it works fine now.. thanks man 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get Page_ID while using Permalinks’ is closed to new replies.