function thumbpost_list_shortcode($atts){ extract( shortcode_atts( array( 'count' => 3, ), $atts) ); $q = new WP_Query( array('posts_per_page' => $count, 'post_type' => 'post') ); $list = '<ul>'; while($q->have_posts()) : $q->the_post(); $idd = get_the_ID(); $list .= ' <li> <img src="<?php echo get_template_directory_uri(); ?>/assets/img/latest-post/1.png" alt="" /> '.get_the_post_thumbnail($idd,'thumbnail').' <p><a href="'.get_permalink().'">'.get_the_title().'</a></p> <span>'.get_the_date('d F Y', $idd ).'</span> </li> '; endwhile; $list.= '</ul>'; wp_reset_query(); return $list; } add_shortcode('latest_post', 'thumbpost_list_shortcode');
Leave a Reply