wordpress - Want to show first 100 characters of recent posts in sidebar then "Read More" -
i'm creating first custom theme on wordpress , trying familiar codex. have "news" section on bottom right of sidebar. want show previews of last 2 posts or so. want show title, date, , first 100 characters or of recent post followed "read more" anchor. idea function can use?
here's 1 way of doing it:
<h2>recent posts</h2> <ul> <?php $args = array( 'numberposts' => '2' ); $recent_posts = wp_get_recent_posts( $args ); foreach( $recent_posts $recent ){ echo '<li>'.$recent["post_title"].' - '.$recent["post_excerpt"].'<a href="'.get_permalink($recent["id"]).'">read more</a></li>'; } ?> </ul>
more info here: http://codex.wordpress.org/function_reference/wp_get_recent_posts
Comments
Post a Comment