2012-12-13, 23:44:24
Hi, in order to show recent post with a specified tag, I have added this function to inc/sidebar.php.
You can specify a tag and an alternative number of recentpost.
Can be useful for the next update?
You can specify a tag and an alternative number of recentpost.
Can be useful for the next update?
PHP Code:
function nm_list_recent_by_tag($tag,$nmrecentposts=0) {
global $NMRECENTPOSTS;
if ($nmrecentposts <= 0 )
$nmrecentposts = $NMRECENTPOSTS;
if (trim($tag)==='') {
return;
}
$posts = nm_get_posts();
if (!empty($posts)) {
echo '<ul>';
$posts = array_slice($posts, 0, $recentposts, true);
foreach ($posts as $post) {
$pos = strpos($post->tags,$tag);
if ($pos !== false) {
$url = nm_get_url('post') . $post->slug;
$title = strip_tags(strip_decode($post->title));
echo "<li><a href=\"$url\">$title</a></li>";
}
}
echo '</ul>';
}
}