Crack at a WordPress Plug-in
The plug-in displays 4 posts from a specific category.
The plug-in needs 3 parameters or you could just modify the code to not use them.
Usage: get_me_4_from_cat($category_id, $postmeta_key, $postmeta_value);
This was written to get 4 random events from a specific post category.
The addition of the postmeta variables enables an additional check for the event since posts weren’t being deleted. This example is based on the 2 digit year the event occurs in. (e.g. For 2008 one would put in ’08’ in the string for the function) The custom field key ‘year’, with this configuration, is added to the post and 08 is added for its value. This can be adapted to any postmeta key/value pair.
Example of use in Theme File:
<?php $randomPosts = get_me_4_from_cat(24, ‘year’, ’08’);
foreach ($randomPosts as $post):
<a href=”<?php the_permalink() ?>” rel=”bookmark”>
<?php the_title(); ?>
<?php the_excerpt(); ?>
<a href=”<?php the_permalink() ?>” class=”moreSpot” title=”Read More”>
else : ?>
<h2> Not Found</h2>
<?php endif; ?>
You can download the plug-in file here.