--- wp-category-posts.php 2008-09-20 01:11:05.000000000 +1000
+++ wp-category-posts.php 2008-09-20 01:11:00.000000000 +1000
@@ -8,13 +8,29 @@
Author URI: http://watershedstudio.com/
*/
-function wp_cat_posts( $catID = 0 ) {
+/**
+ * Lists the posts in a specific category based on parameters.
+ *
+ * @param int $catID The ID of the category you want to print. Defaults to 0 ("uncategorized").
+ * @param int $num The number of posts you want to list. Defaults to 0, meaning unlimited.
+ * @param string $format How you want to output the list. Defaults to 'none', meaning no special formating. Other option is 'list', meaning wrapped within
and tags.
+ * @return void
+ */
+function wp_cat_posts( $catID = 0, $num = 0, $format = 'none' ) {
$catID = (int) $catID;
- $posts = get_posts(array('category' => $catID, 'numberposts' => -1, 'order' => ASC, 'orderby' => title));
+ $posts = get_posts(array('category' => $catID, 'numberposts' => (int) $num, 'order' => ASC, 'orderby' => title));
- foreach( (array) $posts as $post ) {
- echo '' . $post->post_title . '
';
- }
+ foreach( (array) $posts as $post ) {
+ switch ($format) {
+ case 'list':
+ print '' . $post->post_title . '';
+ break;
+ case 'none':
+ default:
+ print '' . $post->post_title . '
';
+ break;
+ }
+ }
}
-?>
\ No newline at end of file
+?>