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.

Let's say I have a post called "Hello World" and I am on that page... Let's say I have different posts like "Haaaa" and "Hoooo".... What I want to do is showing Haaa and Hooo in a different place (let us say the sidebar) if this "Hello World" post is being watched...

So in the sidebar we get this:

Heeee
Haaaaa
<div class="highlighted active"> Hello World </div>
Hoooooo
Hxxxxx
Hzzzzzz

Where do I start? I guess <?php wp_get_archives('type=alpha'); ?>, but how do I get what I want?

share|improve this question
add comment

1 Answer

For the solution you can use if statement as below
put it in your sidebar, it will highlight the current post title.

<ul>
<?php
$IDOutsideLoop = $post->ID;
$args = array( 'posts_per_page' => -1, 'orderby'=> 'title', 'order' => 'ASC' );
$myposts = get_posts( $args );
foreach($myposts as $post) :
?>
<li <?php if(is_single() && $IDOutsideLoop == $post->ID) print 'style="font-weight:bold";' ?>><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>

Even wordpress provides for highlighting the current pages here,
http://codex.wordpress.org/Dynamic_Menu_Highlighting
it doesn't include to hightlight the specific post's title at sidebar.

I don't know if you are looking for static navigation , the below link might help you .
http://blog.huidesign.com/automatically-highlight-current-page-in-navigation-with-css-jquery/

share|improve this answer
    
How does this do it in an alphabetic order? Highlighting the current post isn't a problem (I guess, haven't looked on that one), but outputting 5 posts alphabetically before and after the current post is a big problem... I guess this does not do the thing I want. –  user1627363 May 14 '13 at 9:30
    
I re-changed the codes as an array 'oder' => 'ASC' . hope it work for you. –  Ronald May 14 '13 at 9:42
    
Thanks, but it does not do what I want. Let's say you are on single.php and you clicked a post called "Hello"... What I want it to do is that it outputs the 5 posts that are alphabetically before the post and 5 posts that are after the post (also alphabetically)... I appreciate your help, but it doesn't solve this problem. –  user1627363 May 17 '13 at 9:40
    
No one who can help? –  user1627363 May 23 '13 at 14:44
add comment

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.