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.

Possible Duplicate:
Looking for a Table of Contents (TOC) plugin for WordPress

I have been trying for some time to do one thing: I need a navigation menu inside a Wordpress post which will guide the user to different subsections of my post, and then maybe use a "Top" button to go back to the top. Let me give you an example:

Title

Introduction "jnkdjajkfa"

Menu

Section one - this is a link

Section two - this is a link

Conclusion - this is a link

Section one "bdsjkbdfsjbfjkasbjkbfasbjf"

Back to top - this is a link

Section two "dnjsdkfhbsjukfbajfkbjkfbkasbfjk"

Back to top - this is a link

Conclusion "ndjasndkasnj"

Back to top - this is a link

I know I can do this in the code, but it's really a pain to do it on every post. Do you know a plugin, method to easily do this? Any help is very appreciated.

share|improve this question

marked as duplicate by toscho Jan 2 '13 at 23:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
Are you looking for "Table of Contents" feature? –  Michal Mau Feb 27 '12 at 13:38
add comment

1 Answer 1

You can simply put The code in the php file in your theme.If you use twentyeleven theme open content-single.php, find the line

<h1 class="entry-title"><?php the_title(); ?></h1>

And after it put your divs and top menu.

Another option is to create a widget where you could easily update the html code.

Instead your divs, below this line

<h1 class="entry-title"><?php the_title(); ?></h1>

paste this:

<?php if ( ! dynamic_sidebar( 'links-below-post-title' ) ) : ?>

Also in fuctions.php after

function twentyeleven_widgets_init() {

add this:

register_sidebar( array(
        'name' => __( 'Links Below Post Title', 'twentyeleven' ),
        'id' => 'links-below-post-title',
        'before_widget' => '',
        'after_widget' => "",
        'before_title' => '',
        'after_title' => '',
    ) );
share|improve this answer
    
And what do I do if I want to have more than a fixed number of sub-menus? Your idea is good, but I would need something a bit more dynamic. Thanks a lot! –  Daniel Feb 27 '12 at 12:50
    
@Daniel I updated the answer.I hope html in widget is dynamic enough :) .It even says "dynamic_sidebar" in the code, so it must be so ;D –  Tomas Feb 27 '12 at 13:18
    
I will try it out just now and will get back to you. I can't quite understand everything, but I'll come back as I work on the problem. Thanks! –  Daniel Feb 27 '12 at 13:29
    
I don't think I have actually made myself clear on this one. What I actually want is a menu inside the post as the one you can see here: shapeasmile.com/… . I hope I can post links as examples. But I wanted to make it more dynamic, and not hardcoded. Your widget is nice (Thanks, I learned how to make a widget area), but it's just not showing up in my posts. –  Daniel Feb 27 '12 at 13:40
    
@Daniel go to wp admin add some content in the widget area and it must show up.I didn't tried it myself, but I've done exactly that with another theme and it worked fine. In order to have a widget in the middle of the post try to use this example themeshaper.com/forums/topic/… –  Tomas Feb 27 '12 at 13:52
show 4 more comments

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