jeudi 25 juin 2015

Echo a class if current page matches the li name in wordpress

I'm trying to find some logic that will echo a class only if the current page title matches the title in the li. I'm having trouble coming up with an 'if' statement that won't apply to all the li in this query.

This is in wordpress.

Here's the context:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
   <li><a href="<?php the_permalink(); ?>" <?php if(NEED LOGIC HERE) echo 'class="current"'; ?>><?php the_title(); ?></a></li>
<?php endwhile; wp_reset_query(); endif; ?>

Any help would be much appreciated!

Aucun commentaire:

Enregistrer un commentaire