• Hello everyone, I am having a little problem with a list of links to wordpress pages. This is what I am trying to implement:

    <?php if ($page_id == ‘2’) {echo “
    <li class=\”current\”>Profile
    “;}
    else {echo “

    • Profile
    • “;} ?>

      To put it simple it is supposed to be a system printing different text depending on the current page id. That way I can give a .current class to a li element, like I do in the example. It always worked flawlessly until the moment I activated a different kind of permalinks to have a more user friendly URL for the blog pages. I do not know wordpress in depth and I did not find enough informations on the matter around the web. Would anybody mind giving me a couple of things on how to solve this problem, maybe a workaround or a easier system ro recognize the page I am in in wordpress and how to use it in a php loop?

      Thanks everyone.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jockerworks

    (@jockerworks)

    mmh, maybe I did not really give an attractive title to this topic… any tips anyone? ??

    I don’t know if you find a solution for your problem but this isthe one it works fine:

    <?php
    if ( is_page('2')) {
           echo ("BLABLABLA");
        }
        else {
           echo ("Second BLABLABLA");
         }
    ?>

    2 is your page id.

    Cheers,
    $me

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WordPress page_id in a loop – not working with enhanced permalinks’ is closed to new replies.