Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This is a second navigation menu I'm using:

    <ul id="forums">
        <?php $custom_posts = new WP_Query(); ?>
        <?php $custom_posts->query('post_type=bbp_forum'); ?>
        <?php while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?>
            <li><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></li>
        <?php endwhile; ?>
    </div><!-- #access -->

Is a custom loop which list a custom post type called Forum.

I would like to highlight the current Forum link, like this:

enter image description here

Any suggestions?

share|improve this question
    
Where is this code located? Is it in the header? Or in single.php? Is it executed only within a single post? –  Lea Cohen Mar 13 '11 at 10:19
    
@Lea Cohen in the header. –  janoChen Mar 13 '11 at 18:02

1 Answer 1

up vote 2 down vote accepted

So, if I understand correctly, when you're on a single post page, you want to have a navigation menu with all the posts of post_type bbp_forum.

I had a similar case (without the post_type, but it's not a problem to add it), and I used code that I found that talked about posts of same category, on single post pages.

The code goes as follows (with customization for post_type):

<ul>  
  <?php global $post; $cat_posts = get_posts('post_type=bbp_forum');
  foreach($cat_posts as $post) : ?>  
    <li <?php if($post->ID == get_the_ID()){ ?>class="cur_post" <?php } ?>>
        <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) );  rel="bookmark"?>" ><?php the_title(); ?></a>
     </li>
  <?php endforeach; ?>
</ul>

I hope that's what you meant.

P.S - I also see that you have an opening <ul> tag, but a closing <div> tag....

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.