Last active
April 22, 2017 08:16
-
-
Save ssbalakumar/b89eee496bcab1a247efc141e997960a to your computer and use it in GitHub Desktop.
Recent Posts WP
This file contains hidden or 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
<div class="row"> | |
<h3>Recent Posts</h3> | |
</div> | |
<div class="row recent-post-style"> | |
<ul> | |
<?php | |
$args = array( 'numberposts' => '5' ); | |
$recent_posts = wp_get_recent_posts( $args ); | |
foreach( $recent_posts as $recent ) { | |
echo '<li><a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' . $recent["post_title"].'</a> </li> '; | |
echo wpautop(wp_trim_words($recent["post_content"], 10)); | |
} | |
?> | |
</ul> | |
</div> | |
Final Styling | |
-------------- | |
<div class="row"> | |
<?php | |
$recent_posts = wp_get_recent_posts(array( | |
'numberposts' => 4, | |
'orderby' => 'post_date', | |
'order' => 'DESC', | |
'post_type' => 'post', | |
'post_status' => 'publish' | |
)); | |
foreach($recent_posts as $post) : ?> | |
<div class="col-md-3 col-sm-6 col-xxs-6"> <a href="<?php echo get_permalink($post['ID']) ?>" class="media-box"> <?php echo get_the_post_thumbnail($post['ID'], array(370,250)); ?></a> | |
<div class="grid-item-inner"> | |
<div class="post-item-meta"> <i class="zmdi zmdi-calendar"></i> <?php echo get_the_date('', $post->ID); ?> </div> | |
<h4><a href="<?php echo get_permalink($post['ID']) ?>" title="<?php echo $post['post_title'] ?>"> <?php echo $post['post_title'] ?> </a></h4> | |
<?php echo wpautop(wp_trim_words($post["post_content"], 15)); ?> | |
<div class="meta-data"><a href="#" class="meta-author"><?php _e( 'by ', 'thunder' ); ?> <?php the_author_posts_link(); ?></a> | |
<a href="<?php echo get_permalink($post['ID']) ?>" class="meta-link"><i class="zmdi zmdi-arrow-right"></i></a> | |
</div> | |
</div> | |
</div> | |
<?php endforeach; wp_reset_query(); ?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah nice work