Latest News
This short code display the latest news
// Add Shortcode function latest_posts_shortcode( $atts , $content = null ) { // Attributes extract( shortcode_atts( array( 'post' => '1', 'order' => 'DESC', 'orderby' => 'title', ), $atts ) ); // Code $latest_news .= '<h2>' . $content . '</h2>'; $latest_news .= '<ul>'; query_posts(array('orderby' => $orderby, 'order' => $order , 'showposts' => $posts)); if (have_posts()) : while (have_posts()) : the_post(); $latest_news .= '<li><a href=" '.get_permalink().' ">'.get_the_title() . ' </a> <br>'; $latest_news .='<span class="date">' .get_the_date('d M') . '</span>'; if($exc === true)$latest_news .='<p class="excerpt">' . get_the_excerpt() . ' </p>'; if($thumb === true)$latest_news .='<div class="post_img">'. get_the_post_thumbnail( $thumbnail->ID, 'thumbnail' ) . '</div>'; if($aut === true)$latest_news .='<span class="author">' . get_the_author() . '</span><br>'; $latest_news .='<span class="comments">' . 'there are ' . get_comments_number() . ' comments</span></li>'; endwhile; endif; $latest_news .= '</ul>'; wp_reset_query(); return $latest_news; } } add_shortcode( 'latest-posts', 'latest_posts_shortcode' );