Hello! Made so it can instead print X random posts for any given category
<?php
/*
Plugin Name: WordPress Category Posts
Plugin URI: http://watershedstudio.com/portfolio/software-development/wordpress-category-posts-plugin/
Description: List the posts in a specific category, slightly edited by Hans Petter to instead print out a given number of random posts from given category
Author: Watershed Studio, LLC
Version: 2.0
Author URI: http://watershedstudio.com/
*/
function wp_cat_posts( $catID = 0, $nposts = 10 ) {
$catID = (int) $catID;
$posts = get_posts(array('category' => $catID, 'numberposts' => -1, 'order' => ASC, 'orderby' => title));
/*foreach( (array) $posts as $post ) {
echo '<a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a><br />';
}*/
if ($nposts > count($posts)) $nposts = count($posts);
foreach( array_rand($posts, $nposts) as $post ) {
echo '<li><a href="' . get_permalink($posts[$post]->ID) . '">' . $posts[$post]->post_title . '</a><br /></li>';
}
}
?>
Like that instead with two values passed to it instead of one, First one being the category. second one the number of random posts to appear for given category.
very nice!