WordPress.org

Forums

[resolved] No menu highlight at single post pages (2 posts)

  1. Masteroa
    Member
    Posted 2 years ago #

    Link to my site: http://exogenesis.nl/
    Structure: each page has its own template in which I use query_posts to show all posts from one category.

    On my website, the active navigation menu item is highlighted (using the class 'current_page_item'). But when you click on 'Read more' at a blogpost (and go to the single page to read the post), the menu item isn't highlighted anymore. How can I keep the current menu item highlighted when visiting a child page? There doesn't seem to be any 'current' class.

    FYI

    This is my navigation menu code

    <?php wp_page_menu('link_after=<span class="menu_seperator"></span>'); ?>

    This is (one of) my template(s) code

    <?php
    /*
    Template Name: Politiek
    */
    ?>
    
    <?php define('WP_USE_THEMES', false); get_header(); ?>
    
    <div id="blog_left">
    	<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("category_name=politiek&showposts=6&paged=$paged"); ?>
    	<?php while ( have_posts() ) : the_post() ?>
    		<div class="content_600">
    			<h1><?php the_title(); ?></h1>
    			<p class="bloginfo">Posted in <?php the_category(', '); ?> on <?php the_date(); ?></p>
    			<?php the_excerpt(); ?>
    			<a href="<?php the_permalink(); ?>"><div class="readmore"></div></a>
    		</div>
    	<?php endwhile; ?>
    
    	<div class="prevnext"> <?php posts_nav_link( $sep, $prelabel, $nextlabel ); ?> </div>
    </div>
    
    <div id="blog_right">
    	<div class="sidebar">
    		<h1>Categorie├źn</h1>
    		<?php wp_list_categories('exclude=1,15,14,17,16,18,19,13&show_count=1&title_li='); ?>
    	</div>
    
    	<div class="sidebar">
    		<h1>Archief</h1>
    		<?php wp_get_archives('exclude=1,15,14,17,16,18,19,13&type=monthly'); ?>
    	</div>
    </div>
    
    <?php get_footer(); ?>

    This is my single(.php) page code

    <?php get_header(); ?>
    
    <div id="blog_left">
    	<?php while ( have_posts() ) : the_post() ?>
    		<div class="content_600" style="padding-bottom:5px;">
    			<h1><?php the_title(); ?></h1>
    			<p class="bloginfo">Posted in <?php the_category(', '); ?> on <?php the_date(); ?></p>
    			<?php the_content(); ?>
    		</div>
    	<?php endwhile; ?>
    
    	<div class="prevnext"> <?php posts_nav_link( $sep, $prelabel, $nextlabel ); ?> </div>
    	<?php comments_template(); ?>
    </div>
    
    <?php get_footer(); ?>
  2. Masteroa
    Member
    Posted 2 years ago #

    Sort of solved. I Used:

    <?php
    if (in_category('politiek')){ $current = 'page-item-11'; }
    elseif (in_category('columns')){ $current = 'page-item-9'; }
    elseif (in_category('recensies')){ $current = 'page-item-16'; }
    elseif (in_category('reizen')){ $current = 'page-item-293'; }
    elseif (in_category('fotografie')){ $current = 'page-item-13'; }
    ?>
    <style type="text/css">
    .<?php echo $current; ?> {
    background-image: url('http://exogenesis.nl/wp-content/themes/exogenesis/images/navigation_active.png');
    background-repeat: no-repeat;
    background-position: center;
    }
    </style>

    in the header

Topic Closed

This topic has been closed to new replies.

About this Topic