Created
April 2, 2020 13:40
-
-
Save prosantamazumder/92a65b947bf7f58d95f0f22ffd518cac to your computer and use it in GitHub Desktop.
You Can Use The Code in WordPress CMS Custom Post loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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