Conditional tags not working inside the loop
-
I have the following code. It’s a Menu built with a custom loop of sub-pages of a custom post type. All I wanna do is add a class “selected” if the current page is showing:
<ul class="menu3"> <li><a href="<?php echo qtrans_convertURL(get_permalink($post->post_parent), qtrans_getLanguage()); ?>" class="<?php if (is_single($post->post_parent)) { echo 'selected'; } ?>"><?php _e('[:en]Overview[:es]Resumen[:pt]Vis?o Global'); ?></a></li> <?php $parent = $post->ID; $chil = $post->post_parent; ?> <?php if ( $post->post_parent ) {?> <?php query_posts('post_type=projects&orderby=menu_order&order=ASC&post_parent='.$chil); ?> <?php } else { query_posts('post_type=projects&orderby=menu_order&order=ASC&post_parent='.$parent); } while (have_posts()) : the_post (); ?> <li><a href="<?php echo qtrans_convertURL(get_permalink(), qtrans_getLanguage()); ?>" class="<?php if ( is_single( get_the_ID() ) ) { echo 'selected';} ?>"><?php echo the_title(); ?></a></li> <?php endwhile; ?> </ul>
But the conditional tag, appears to not working at all. Exactly this part of the code isnide the loop:
class="<?php if ( is_single( get_the_ID() ) ) { echo 'selected';} ?>"
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Conditional tags not working inside the loop’ is closed to new replies.