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.

i do menu with this code but links redirect me too archive.php

<ul id="nav">
    <?php
    $all_posts = get_posts(array(
      'posts_per_page' => -1 // to show all posts
    ));

    // this variable will contain all the posts in a associative array
    // with three levels, for every year, month and posts.

    $ordered_posts = array();

    foreach ($all_posts as $single) {
        $year  = mysql2date('Y', $single->post_date);
        $month = mysql2date('F', $single->post_date);
        // specifies the position of the current post
        $ordered_posts[$year][$month][] = $single;
    }
    $classplus = 0;
        // iterates the years
        foreach ($ordered_posts as $year => $months) { ?>
        <li>
            <a class="lever year<?php echo $classplus; ?>"><?php echo $year ?></a>

            <ul class="active">
            <?php foreach ($months as $month => $posts1 ) { // iterates the moths ?>
            <?php foreach ($posts1 as $single ) { // iterates the posts ?>
                <li>
                    <a href="<?php echo get_permalink($single->ID); echo '#post-'.$single->ID;?>"><?php echo get_the_title($single->ID); ?></a></li>
                </li>
            <?php } // ends foreach $posts ?>

            <?php } // ends foreach for $months ?>
            </ul>

        </li> <?php
        } // ends foreach for $ordered_posts
        ?>
    </ul>

I want link too single.php not archive.php. Help me... :)

share|improve this question
    
What do you mean "redirected"? Do links have expected values but lead to unexpected place? Or are the links themselves wrong? –  Rarst Sep 24 '13 at 20:18
    
Your code works, links are ok (they point to posts), the problem must be in your templates. –  Dan Ștefancu Sep 24 '13 at 22:11

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.