WPforSale

Premium WordPress Products
  • Home
  • Blog
  • Cool Stuff
  • Plugins
  • Themes
    • Magazine
    • News
    • Video
  • Contact

WordPress Hack | Set Class for Home Page Link

19.08.2008 0

The Problem:

Needed the home page button status to appear active, or in WP terms, as the “current_page_item”. So I need to determine if the page I was on was the home page or not, and if it was, I needed to add a class to it of “current_page_item”.

Solution:

Just a little PHP script does the trick- added into the LI element.

<ul>
<li <?php if (is_home())
echo ‘class=”current_page_item”‘;?>
><a href=”<?php echo get_settings(’home’); ?>/”>Home</a></li>
<?php wp_list_pages(’sort_column=menu_order&depth=1&title_li=’);?>
</ul>

That’s it!

NOTE: Here is a useful plugin to check out and that I am using with the code above: Current-Page-Bugfix

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • del.icio.us
  • Facebook
  • Google
  • BlinkList
  • Blogosphere News
  • E-mail this story to a friend!
  • Fark
  • Furl
  • Reddit
  • StumbleUpon
  • Technorati
  • TwitThis
  • YahooMyWeb

No comments

Leave a reply

    Check These Out

    • Advertise Here
  • AD Mangement

    The ads on this page are managed using the OIOPublisher plugin. Keep 100% of your ad revenue and allow others to purchase ads right on your site. Great way to make extra money on your site. Learn more on our post about it: Banner Ad Management Plugin for WordPress
WPforSale is proudly powered by WordPress | © WPforSale a part of the Bernadot Studios network.