Add Class When Show Custom Post Type Fetch

<?php

$args=array( ‘post_type’=>’service’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 3, ‘orderby’ => ‘date’, ‘order’ => ‘ASC’, ‘caller_get_posts’=> 1); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() )$i=1; while ($my_query->have_posts())
: $my_query->the_post();
if( $i==1 ){
$class1 = ‘in’;
$class2 = ‘up’;
$class3 = ‘One’;
}
elseif( $i==2 ){
$class1 = ”;
$class2 = ‘down’;
$class3 = ‘Two’;
}
else{
$class1 = ”;
$class2 = ‘down’;
$class3 = ‘Three’;
}

?>
href=”index.html#collapse<?php echo $class3 ?>”
<?php the_title(); ?>
<i class=”glyphicon glyphicon-chevron-<?php echo $class2 ?>” style=”float: right;font-size: 13px;”></i>
id=”collapse<?php echo $class3 ?>” class=”panel-collapse collapse <?php echo $class1 ?>”>
<?php the_field(‘service_full_description’, $post->ID); ?>

<?php $i++; ?>
<?php endwhile; wp_reset_query(); ?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

Up ↑

%d bloggers like this: