Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function noel_recent_projects($atts) {
- extract(shortcode_atts(array(
- 'count' => 3,
- 'thumbs' => true,
- 'time' => false
- ), $atts));
- /* generate list from thumbs and links to projects */
- $projects = get_posts(array(
- 'numberposts' => $count
- ));
- $list = '';
- foreach($projects as $item){
- $list .= '<li>';
- if( (bool) $thumbs && has_post_thumbnail($item->ID) ) {
- $list .= get_the_post_thumbnail($item->ID, array(40,40));
- }
- $list .= '&nbps;&nbps;&nbps;<a href="#/' . esc_attr($item->post_name) . '">' . get_the_title($item->ID) . '</a>&nbps;&nbps;&nbps;';
- if( (bool) $time) {
- $list .= '<time class="timeago" datetime="' . $item->post_date . '">' . get_the_time('',$item->ID) . '</time>';
- }
- $list .= '</li>';
- }
- return '<ul class="latest-projects latest-posts">' . $list . '</ul>';
- }
- add_shortcode('noel_recent_projects', 'noel_recent_projects');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement