Category names in menu
-
Hi there,
I’m trying to realize a menu with five randomly picked posts incl. the categories but I don’t quite know how to do it.
This is what I have so far, included in the header.php:
<li><a href="#">Stöbern</a> <ul> <?php $lastposts = get_posts('numberposts=5&orderby=rand'); foreach($lastposts as $post) : setup_postdata($post); global $post; $categories = get_the_category($post->ID); var_dump($categories); ?> <li<?php if ( $post->ID == $wp_query->post->ID ) { echo ' class="current"'; } else {} ?>> <a href="<?php the_permalink() ?>"><?php the_title(); ?> von <?php echo the_category('name')->name; ?> </a> </li> <?php endforeach; ?> </ul> </li>
Can anyone help me with that please?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Category names in menu’ is closed to new replies.