10.1.10 – Plugin has been updated to allow you to choose the order of posts if not displaying randomly.
The other day I was in desperate need of a good, random, related posts plugin. In the end, I couldn’t find exactly what I needed so I thought I would just make it myself!Download
This plugin is a very lightweight method of including random related posts anywhere on your signle.php template. It has a variety of options available, including:
- Choose the number of Posts to show
- Choose whether it displays these posts randomly, or in order of newest post.
- Choose whether to display a title, what tags to use, and what text should be displayed (e.g. H3)
- Choose a class for the main ul
- Upload the `random_related_posts_by_cat` directory to the `/wp-content/plugins/` directory.
- Activate the plugin through the ‘Plugins’ menu in WordPress.
- Place `<?php relatedPosts(); ?>` in your templates – please see the description for more options.
To edit the options available, use the following codes:
<?php relatedPosts( $ppp = 4, $rand = true, $rPinctitle = true, $rPtitletag = 'h3', $rPtitle = 'Related Posts', $rPulclass = 'related_posts', $orderby = 'title', $order = 'ASC' ); ?>
- $ppp = Number of posts to display (Any integer allowed)
- $rand = sets the display to random (true/false)
- $rPinctitle = Displays the title (true/false)
- $rPtitletag = The type of tag to wrap the title in (Default h3, but it can be any valid HTML tag)
- $rPtitle = The title to be displayed (This can be any text value)
- $rPulclass = This sets the class of the ul (This can be any text value)
- $rPexcerpt = Allows you to choose whether to display the excerpt (true/false)
- $orderby = This allows you to order the posts by certain parameters (title/author/date/modified/menu_order/parent/ID/none/comment_count) If you want to choose the order of your posts, be sure to set $rand to false
- $order = This can either be Ascending or Descending (ASC/DESC)
I will continue to develop this plugin if I need to, so feel free to make any requests in the comments!Download