Support » Themes and Templates » Highlight current page on sidebar's menu list

  • Resolved theredborough


    Hi! I know that if I’ll use <?php wp_list_pages(); ?> that I’ll have a current_page_item class. But I also need to display a custom field value called “category” so I opted not to use wp_list_pages.

    Anyway, I added a menu list on my sidebar where it features the child pages for let say “Articles”. I would to be able to highlight the “active page” on the menu list. I was thinking of adding some variable like $current_page = so I can add a class and use that in my CSS. I just don’t know where I should put it. Also I’m not using sidebar widgets – if that’s a useful information for you guys.

    I’m a little new in WordPress.

    Here is the code I used:

    <div class="posts">
    	 $parent_id = get_post(44);
    	$args = array(
    	'post_type' => 'page',
    	'posts_per_page' => -1,
    	'post_parent' => $parent_id->ID,
    	'order' => 'ASC',
    	'orderby' => 'menu_order'
    	$parent = new WP_Query ( $args );
    	if ($parent->have_posts () ) :
    	  <?php while ($parent->have_posts()): $parent->the_post(); ?>
                      <a href="<?php the_permalink(); ?>">
    				 <h4><?php the_title(); ?></h4>
    				 <h6><?php echo get_post_meta($post->ID, "category", true); ?></h6>
    	 <?php endwhile; ?>
    	<?php endif; wp_reset_query(); ?>	

    Thank you in advance!

  • The topic ‘Highlight current page on sidebar's menu list’ is closed to new replies.