What i want to make:
I want to make a navigation menu where every dropdownbar is its own post type.
- Movie
- movie1
- movie2
- Book
- book1
- book2
- Game
- game1
- game2
What i've made so far:
I'm not the best at php yet, but i tried to work something out:
echo "<ul class="menu">";
$post_type = get_post_types( array('Movie', 'Book', 'Game') );
foreach( $post_type as $type ) {
$args = array(
'post_type' => $type
);
echo "<li>".$type."<ul class="dropdown">";
$posts = get_posts( $args );
if( $posts ) {
foreach( $posts as $post ) {
echo "<li>".get_the_title( $post->ID, 'title' )."</li>";
}
echo "</ul></li>";
}
}
echo "</ul>";
Question:
Is there a smarter way to make the dropdownmenu? or what can i do to make it work?