Im trying to create an array for my bespoke homepage template which gets the title, category, featured thumbnail and excerpt from the last 3 blog posts and puts them into the correct divs for styling.
So far i have managed to come up with the following:
<div id="content2Wrapper"> <?php $args = array( 'numberposts' => 3, 'order'=> 'DSC', 'orderby' => 'date' ); $postslist = get_posts( $args ); foreach ($postslist as $post) : setup_postdata($post); ?> <div> <div id="widget2left"> <h3><?php echo substr(get_the_title(),0,58); ?></h3><p> <h5><?php echo substr(the_category(),0,70); ?></h5> <p><?php echo substr(get_the_excerpt(),0,165); ?><p> <br> <p><?php the_post_thumbnail(220,120,true); ?> </p> </div><!--end widget 2 left--> </div>
But as you can see this displays 3 posts order by date, but the substr code is cutting the ends of words off & also the images are not displaying at the 220*120 resolution.
here is an image of what i am trying to acheive http://s16.postimg.org/eqqsent91/screen2.png
My code knowledge is rusty so any help to improve this code would be really helpful.