Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save prosantamazumder/92a65b947bf7f58d95f0f22ffd518cac to your computer and use it in GitHub Desktop.
Save prosantamazumder/92a65b947bf7f58d95f0f22ffd518cac to your computer and use it in GitHub Desktop.
You Can Use The Code in WordPress CMS Custom Post loop
//Here is the code
<?php if ( $posts->have_posts() ) : //IF POST AVAILABLE
$count = 1;
$Number = 1;
while( $posts->have_posts() ) : $posts->the_post(); //WP CUSTOM QUERY
// GET POST SUPPORT DATA
$thumbnails = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full');
$content = wp_trim_words( get_the_content(), '250', '....' );
// WORDPRESS POST COUNT ODD ADD EVEN POST ADD DIFFERENT CLASS
if($Number % 2){
$active = 'fadeInLeft';
}else{
$active = 'fadeInRight';
}
//WORDPRESS FIRST POST ADD CLASS
if( $count == 1){
$activeblock = 'active-block';
$active = 'active';
$current = 'current';
}else{
$activeblock = ' ';
$active = ' ';
$current = ' ';
}
?>
<div class="timeline-content wow <?php echo $Number; ?> <?php echo $active; ?>"></div>
<?php $Number++; $count++; endwhile; wp_reset_postdata(); ?>
<?php else : //ECHO POST NOT FOUND ?>
<?php esc_html_e( 'Sorry, No Post matched your criteria'); ?>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment