If permalink is equal to current site url

I would do something simplier using ID :

<?php $current_id = $post->ID; ?>
<?php query_posts('orderby=name'); ?>  
<?php while (have_posts()) : the_post(); ?>

   <li>
       <?php $current_class = ( $current_id == $post->ID ) ? 'class="current"' : ''; ?>
       <a <?php if ( $current_class ) echo $current_class; ?> href="https://wordpress.stackexchange.com/questions/88833/<?php the_permalink() ?>">
          <?php the_title() ?>
       </a>
   </li>

<?php endwhile; ?>
<?php wp_reset_query(); ?>

I didn’t had time to verify code, hope this helps.

Leave a Comment