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... :)