Last active
October 2, 2015 12:00
-
-
Save roborracle/6e643ed1e6b6e02ffc71 to your computer and use it in GitHub Desktop.
Using Foundation 5 in conjunction with jquery masonry to create a custom grid layout of recent posts in a WordPress site with trimmed titles, and trimmed post output.
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
<div class="row"> | |
<div class="small-12 columns"> | |
<div id="masonry-grid"> | |
<?php | |
$args = array( 'numberposts' => '99' ); | |
$recent_posts = wp_get_recent_posts(); | |
foreach( $recent_posts as $recent ) { | |
if($recent['post_status']=="publish"){ | |
echo '<div class="gutter-sizer"></div> | |
<div class="medium-4 small-12 grid-item columns">' | |
. '<div class="fp-featured-image"> ' | |
. get_the_post_thumbnail($recent["ID"], 'featured-image') | |
. '</div>'; | |
$trimtitle = get_the_title($recent["ID"]); | |
$shorttitle = wp_trim_words( $trimtitle, $num_words = 8, $more = '… ' ); | |
echo '<h2 class="myspecial-post-title">' . '<a href="' . get_permalink($recent["ID"]) . '">' . $shorttitle . '</a></h2>'; | |
$trimcontent = get_post_field('post_content', $recent["ID"]); | |
$shortcontent = wp_trim_words( $trimcontent, $num_words = 20, $more = '… ' ); | |
echo '<p>' . $shortcontent . '</p>' | |
. '<p class="gb-more-link"><a href="' . get_permalink($recent["ID"]) . '"> View Submission <i class="fa fa-play"></i> </a></p>' | |
. '</div>'; | |
}} | |
?> | |
</div> | |
<!--end masonry-grid--> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment