Give active class to current page on a while loop WP query for custom post types listing
I have a single-programs.php page and at the top of this single page I need to list all the entries from the custom post type programs. Is there a way to give active class to this list for the current page (current single post type ?
Here is my code:
?php
$args = array(
'numberposts' = -1,
'post_type' = 'programs',
'order' = 'ASC'
);
$the_query = new WP_Query( $args );
?
?php if( $the_query-have_posts() ): ?
ul
?php while( $the_query-have_posts() ) : $the_query-the_post(); ?
li
span class=background/span
h3 class=title?php the_title(); ?/h3
a href=?php the_permalink(); ?/a
/li
?php endwhile; ?
/ul
?php endif; ?
?php wp_reset_query(); // Restore global post data stomped by the_post(). ?
This code is generating a list with my 4 items related to programs, however I need to include a class active to the current single page.
Topic single custom-post-types Wordpress
Category Web