Super recent news WordPress shortcode

Here is the WordPress shortcode that can be used from sidebars. It will list the two latest posts from the “news” category.

In order to use it you shuold write [superrecentnews] in any text widget from any sidebar.

// super recent news

function srn() {

query_posts('category_name=news&showposts=2');

while (have_posts()) {

	the_post(); 

	$str = $str . '
'; $str = $str . "

" . get_the_title() . "

" . "
"; } return $str; } add_shortcode('superrecentnews', 'srn'); add_filter('widget_text', 'do_shortcode');

Here is how it looks.

Super recent news code differs from the Recent Posts widget that comes together with Wordpress: it contains only the post from a specified category “news” and it shows the dates of the posts.

Thanks

tags: & category: -