Forums

2.5 is_page(array... issues :( (7 posts)

  1. sincewelastspoke
    Member
    Posted 4 years ago #

    Hi,

    I've got WP 2.5.

    And I have a page on my web site called 'Career Development', currently accessed by index.php?page_id=30. So I've added the following to my sidebar, so that if I'm on that page, the link will be bold.....except it doesn't work :(

    <?
    if (is_page(array(30,'career-development','Career Development'))) {
    	echo '<li class="bold"><a href="index.php?page_id=30">Career Development</a></li>';
    } else {
    	echo '<li><a href="index.php?page_id=30">Career Development</a></li>';
    }
    ?>

    I obviously have a .bold {font-weight:bold} in my CSS.

    It works for my is_category() if statements, but just not this :(

    Can anyone make any suggestions why it isn't working?

    Many thanks!

  2. sincewelastspoke
    Member
    Posted 4 years ago #

    Hate to *bump*, but any ideas anyone?

    Thanks for your time.

  3. iridiax
    Member
    Posted 4 years ago #

    Are 30, 'career-development', and 'Career Development' all the same page? If so, then this is an error, and you only need one and shouldn't use an array. I just noticed your permalinks, so I'd use 30 of the three choices.

  4. sincewelastspoke
    Member
    Posted 4 years ago #

    Thanks for the reply :) Yes, they're all the same page.

    page_id = 30
    page-slug = career-development
    page-title = Career Development

    I used the array just to future proof it. Right now we're using index.php?page_id=30 but in the future plan to change the htaccess/rewrite engine so it uses the page title 'Career Development'.

    So you reckon just use if (is_page('30')) { for now ?

    Thanks.

  5. iridiax
    Member
    Posted 4 years ago #

    Yes, the ID works even if you have pretty permalinks.

  6. sincewelastspoke
    Member
    Posted 4 years ago #

    Aaaah cool, I'll just use the ID then. Fingers crossed :)

  7. sincewelastspoke
    Member
    Posted 4 years ago #

    Brilliant, that worked.

    Maybe I should have stuck with the ID instead of trying to be smart hehe.

    Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.