WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Get Page_ID while using Permalinks (3 posts)

  1. cyph1
    Member
    Posted 6 years ago #

    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

  2. stvwlf
    Member
    Posted 6 years ago #

    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

  3. cyph1
    Member
    Posted 6 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic