Friday, November 6, 2015

Single Page Current post Active Class

<?php if (have_posts()) : while (have_posts()) : the_post(); $current_project = get_the_ID(); ?>

Post Loop Header Before :






       <?php

$args = array( 'post_type' => 'knowus', 'posts_per_page' => 5, 'post_status' => 'any', 'post_parent' => null );

$attachments = get_posts( $args );

if ( $attachments ) {

foreach ( $attachments as $post ) {

setup_postdata( $post );

?>

   

    <?php if ( $post->ID == $current_project ) { ?>

    <li class="active"><a href="<?php the_permalink();?>">

      <?php the_title();?>

      </a></li>

  <?php } else { ?>

    <li><a href="<?php the_permalink(); ?>">

      <?php the_title();?>

      </a></li>

  <?php } ?>

   

   

    <?php }

wp_reset_postdata();

}
?>

No comments:

Post a Comment