I use categories to the main navigation in wordpress. To show my category "Home" (start page), I use the following code in index.php. "Home" is category 4.
<?php if ( have_posts() ) : ?> <?php query_posts("cat=4"); //set cat 4 to start page ?>
<?php /* Start the Loop */ ?>
The problem is that when someone visits my site are "Home" not marked as current page. But if a click on "Home" is it highlighted as current page.
How do I set category home as the current page when someone visits my site? Can i include the css in my php code above?
Have the following in in my css that works when you click on a link (category) in the main menu, but not when someone visits the web page without clicking in the menu.
.main-navigation .current-menu-item > a,
.main-navigation .current-menu-ancestor > a,
.main-navigation .current_page_item > a,
.main-navigation .current_page_ancestor > a {
color: #ffffff;
background-color: #f68a1f;
}
My menu code looks like this (use wordpress menu)
<nav id="site-navigation" class="main-navigation" role="navigation">
<h3 class="menu-toggle"><?php _e( 'Meny', 'twentytwelve' ); ?></h3>
<div class="skip-link assistive-text"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?></a></div>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
</nav><!-- #site-navigation -->