Hey Paul,

Thanks for this great tip. I was about to start asking questions when I
found this helpful article that goes fairly in-depth:

http://www.nathanrice.net/blog/wordpress-2-8-and-the-body_class-function/

Sure beats inserting all that PHP code, ala "$thisPage" and such.

Cheers,

Art Thompson, Jr.
Logical Things - Design + Technology
917-609-1158 [m]
512-692-9865 [w]
www.logicalthings.com
linkedin.com/in/logicalthings
twitter.com/logicalthings


On Tue, Sep 22, 2009 at 4:09 PM, Paul <[email protected]> wrote:

>
> Rob,
>
> My preference is to use the new WordPress 'body_class()' function.
> This is added to your theme's HTML Body tag like:
>
> <body <?php body_class(); ?>>
>
> (Not sure how well the PHP code will come through. Check the
> header.php in the default theme which comes with WP)
>
> The 'body_class()' will basically apply CSS class values to your body.
> So now you just need to setup class values on your navigation items.
> This will work out better then attempting to identify the page in your
> LI element with WP PHP functions.
>
>
> so you will need to setup some CSS rules for highlighting the
> appropriate nav item
>
> // This assumes you replace the PHP code in your first (Home) LI item
> to a class like 'class="home" '
> body.home ul.nav li.home a {...}
>
> For a real working example check out http://spark.highwirecreative.com/
> I just worked on some of the development last week. Doing just what
> you are attempting. The 'Blog' section works just like what you are
> attempting.
>
> Paul
>
>
>
>
> On Sep 22, 2009, at 3:57 PM, [email protected] wrote:
>
> >
> >
> > Ok, need a wordpress guru ... this will be easy for ya but its
> >
> >
> > I have a nav menu that I want to highlight based on what page/category
> > the user is in:
> >
> > <ul><!-- main navigation -->
> > <li <?php if(is_home()): ?>class="current_page_item"<?php endif; ?>><a
> > title="Home page" href="<?php bloginfo('url'); ?>"><span>Home</span></
> > a></li>
> >
> > <li <?php if(is_category('Portfolio')): ?> class="current_page_item"<?
> > php endif; ?> ><a href="/category/portfolio">Portfolio</a></li>
> >
> > <li <?php if(is_page('Services')): ?>class="current_page_item"<?php
> > endif; ?> ><a href="/services/">Services</a></li>
> >
> > <li <?php if(is_category('blog') ): ?>class="current_page_item"<?php
> > endif; ?> ><a href="/category/blog/">Blog</a> </li>
> >
> > </ul>
> >
> >
> > This works great.... EXCEPT when you go into an individual blog entry.
> > Then no workie. I tried this:
> >
> > <li <?php if(in_category('blog')  ....
> >
> >
> > but that became true for Home and Services "pages" as well. So finally
> > I came up with:
> >
> > <?php if(in_category('blog')&&(!is_page())&&(!is_home()) )
> >
> > and that worked... but that is lame? Is there a better way? I just
> > want to understand this stuff with resorting to hackery :p
> >
> > Thanks
> >
> > Rob
> >
> >
> >
> > >
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
Our Web site: http://www.RefreshAustin.org/

You received this message because you are subscribed to the Google Groups 
"Refresh Austin" group.

[ Posting ]
To post to this group, send email to [email protected]
Job-related postings should follow http://tr.im/refreshaustinjobspolicy
We do not accept job posts from recruiters.

[ Unsubscribe ]
To unsubscribe from this group, send email to 
[email protected]

[ More Info ]
For more options, visit this group at 
http://groups.google.com/group/Refresh-Austin
-~----------~----~----~----~------~----~------~--~---

Reply via email to