Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.
Notice: I'm taking a break from blogging to focus on Atari Gamer . com, check it out!

NOTE: This article is 3 years or older so its information may no longer be relevant. Read on at your own discretion! Comments for this article have automatically been locked, refer to the FAQ for more details.
This plugin creates a box with a number of links to other posts on the same blog. The look and feel is configurable via CSS. By default it displays 4 random posts, but that can be changed via code. I created this plugin to expose readers to more content and also to create more internal linking.

This is what it looks like when rendered on my blog (using some additional CSS styling):

This is the minimal CSS styling that can be used. The plugin renders an outer DIV with each of the links rendered within its own DIV. This CSS can be added to the existing theme CSS, the plugin does not define where the CSS is to be added.
 Theme CSS style additions
.moreonblog_outer {padding-bottom:6px;}
.moreonblog_inner {padding:6px;padding-bottom:0;}

Below is the code for the plugin. It's written to display only on single posts, meaning it will not display anything when looking at the blog's main page where a list of blog entries is shown. The plugin is registered as a widget with the name 'moreonblog'.
Plugin Name: MoreOnBlog
Plugin URI: http://www.igorkromin.net/
Type: Block
Description: Displays links to the other random posts on the blog.
Author: Igor Kromin
Version: 1.0
Author URI: http://www.igorkromin.net/
function plugin_moreonblog_widget() {
global $fpdb, $fp_config;
$q =& $fpdb->getQuery();
if (($q && $q->single) || isset($fp_params['entry'])) {
$content = zzzzzx();
$widget = array();
$widget['subject'] = 'Other posts on '.$fp_config['general']['title'];
$widget['content'] = $content;
return $widget;
function zzzzzx() {
$q = new FPDB_Query(array('start'=>0, 'count'=>-1, 'fullparse'=>true), null);
$entry = array();
while($q->hasMore()) {
list($id, $e) = $q->getEntry();
$subj = $e["subject"];
$loc = get_permalink($id);
array_push($entry, array($subj, $loc));
$idx = (range(0, sizeof($entry)-1));
$content = '<div class="moreonblog_outer">';
for($i = 0; $i < 4; $i++) {
$v = $idx[$i];
$content = $content .'<div class="moreonblog_inner"><a href="'.$entry[$v][1].'">'.$entry[$v][0].'</a></div>';
$content = $content . '</div>';
return $content;
register_widget('moreonblog', 'MoreOnBlog', 'plugin_moreonblog_widget');

This code needs to be placed in the fp-plugins/moreonblog directory (which needs to be created first). The plugin then needs to be enabled via the admin Plugins page.

Note: there is a known issue with this plugin not working if there are less than 4 posts on a blog. I know this is a limitation and the fix is easy, but I'll leave that to the reader to figure out.


Skip down to comments...
A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. If you spot something out of place, please do let me know.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
comments powered by Disqus
Other posts you may like...