• Hi, my apologies if this is covered elsewhere… I’ve looked and looked for it, but to no avail.

    I’m using WordPress as a CMS for a really small site with nothing but Pages (i.e., no Posts, no blog). I installed the Static Front Page plugin, and it works great.

    My only problem is that when the home page is the current page, that’s not indicated in the navigation with .current_page_item getting appended to the list item <li> as it is for all other Pages. My WordPress site is here:

    http://new.skydogtech.com/wordpress/

    Thanks in advance for any help you can offer.

Viewing 7 replies - 1 through 7 (of 7 total)
  • I use the following code to add the current page attribute in WordPress:

    <?php
    $pg_li="page_item";
    if (is_home()) {$pg_li .=" current_page_item";}
    ?>
    <ul>
    <li class="<?php echo $pg_li; ?>"><a href="<?php bloginfo('siteurl'); ?>" title="Home">Home</a></li>

    If you tweak it to compare the URI instead of the is_home function, it should work for you as well. Let me know if you need any help with it.

    Good luck,
    Michael.

    Thread Starter sugoo

    (@sugoo)

    Thanks so much for your help. Since I’m brand new to PHP, I’m afraid I’m not sure how to implement: would I put the code you indicated just before

    <?php wp_list_pages('sort_column=menu_order&title_li='); ?>

    in my header.php? Thanks again.

    Ok, I did this little block of code up for you, just paste in directly below the <div id="tabs"> tag and you should be good to go (I hope). I’ve commented the code and I’ve placed the URL that you posted above as the homepage link, but you can just change that and the $homepage variable to whatever you need it for.

    Let me know how it goes, good or bad!

    Cheers,
    Michael.

    Thread Starter sugoo

    (@sugoo)

    Wow! This worked like a charm! Only thing I changed was to exclude the home page from wp_list_pages, since you listed it manually right before wp_list_pages. Thanks so much!!!

    You are most welcome!

    I should have made a note of that, because the index page in WordPress (ie the front page) is not an actual page, it normally doesn’t get listed with the wp_list_pages, so I had added it and used the <?php bloginfo('siteurl'); ?> to link it.

    Cheers,
    Michael.

    niziol, can you post the bit of code, instead of linking to the pastebin (which is empty when I click on the link)?

    niziol –

    I’m with skube…the link you provide is blank.

    Could you post it again?

    thanks

    DA

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘static front page plugin and .current_page_item’ is closed to new replies.