I have a custom post type called: "movie"
I have only 4 movies in my movies section in the site.
Inside each movie post type I want to display all other movies in a side list
like so:
- movie 1
- movie 2
- movie 3
- movie 4
so the user can navigate from each movie page to all other movies.
I used this code to display the list of all of my "movie" post types:
<ul>
<?php $loop = new WP_Query( array( 'post_type' => 'movie', 'posts_per_page' => 4, 'order'=>'ASC' ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<li>
<?php the_title( '<a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '">', '</a>' ); ?>
</li>
<?php endwhile; ?>
</ul>
So far it is very simple and working.
I would also like to add a "current" class to each item in the list that corresponds to the post I am currently reading. for instance if I am inside movie 3 I see this:
- movie 1
- movie 2
- movie 3
- movie 4
The problem is that unlike WordPress custom menu, no "current-menu-item" or other class is automatically generated.
any clue how I can accomplish that?