WordPress: External RSS Feeds Optimization with KB Advanced RSS

Apart from its own Ice Tea tech blog, also displays two external feeds relating to Optimization and Standards. I needed to optimize the post titles of these two feeds by getting rid of their long suffixes, both for better looks and for more content within the same space.

The feeds were served by the standard RSS WordPress 2.7.1 widget, which is fine, except it does not support much customization. After some search, I found Advanced RSS 1.0.1 WordPress plugin and KB Advanced RSS 2.1.3 WordPress plugin. Smart RSS only works until WP 2.7.0 and I didn’t want to tweak with that. Advanced RSS only works until WP 2.6.2 and requires PHP5, DOM and XSL extensions loaded on the server and I don’t want to depend on those if I don’t need to, so the choice was easy.

Installation of KB Advanced RSS worked flawlessly right from within wp-admin. Then, on my first attempt to configure it, I came across a problem which could very well had been a show stopper: for some reason, except for the feed’s URL and Title, the widget would not commit any of the other parameters to the “Options” table of the database. Troubleshooting this issue, I ended up reading all the users’ comments on the plugin’s site. As usual, I was not alone; this is a common issue. Thankfully, Wesley of had already posted the solution to PHP4 not committing widget field changes in WordPress. The solution worked like a charm. And, as expected, when I later upgraded to PHP5 the problem wasn’t even there to begin with.

KB Advanced RSS is well thought-out, very straight forward with good documentation and examples. It supports all the features of the standard widget (including multiple instances) plus formatting and full support of all the feed’s fields to display or not (including the debugging tool to show which these fields are)! It further supports two modifiers to optionally manipulate the string before display, by taking out a number of characters from the start (ltrim) and/or trimming it to a specific length (trim).

Alas, what I actually needed was to take out a number of characters from the end of the string. Fortunately, as it turned out, KB Advanced RSS’s code is pretty straight-forward and extending it with my own modifier (rtrim) to do just that was only a matter of 3 lines of PHP code added to the version of the plugin that runs by my version of WordPress; there’s one for versions up to 2.7 (pre-wp-2-7.php) and one for versions after that (post-wp-2-7.php). Here is the PHP code from the modified post-wp-2-7.php (my rtrim extension is in blue):

///////////////////////////////// CUSTOMIZATIONS /////////////////////////////////////////
// If you want to write customizations, put them here. The variable to modify is $text. See the FAQ.

// right trimming
// cuts $rtrim characters from the right
// by ageor, April 9, 2009
$rtrim = (is_numeric($rtrim) && 0<$rtrim) ? (int) $rtrim : null;
if (is_int($rtrim))
$text = substr( $text, 0, strlen($string)-$rtrim );

// left trimming:
$ltrim = (is_numeric($ltrim) && 0<$ltrim) ? (int) $ltrim : null;
if (is_int($ltrim))
$text = substr( $text, $ltrim );

// length trimming (do after left trimming)
$trim = (is_numeric($trim) && 0<$trim) ? (int) $trim : null;
if (is_int($trim))
$text = substr( $text, 0, $trim );

return $text;

The way this is written, the string in question can undergo any mix of all three trimming types necessary.

All setting up and troubleshooting took place by adding one instance of the widget and configuring it, then a second instance. When all was done and I had what I wanted, I removed the original two instances of the original RSS widget, positioned the new ones on top and saved, certain I was done. However, as the resulting “Widgets” WordPress admin page suggested after saving, something was very wrorg. It displayed the message ‘You are using 3 widgets in the “Left Sidebar” sidebar’ but not the widgets themselves, nor the “Save Changes” button. Sure enough, I ended up with an unworkable site, as these where the first 2 widgets on the left column of Ice Tea tech and the page that appeared ended with the title banner. Disaster!

To cut a long story short, plenty of “trial and error”s later and with the help of Vicki of neTWire, here is my conclusion: For KB Advanced RSS widget to work with WP 2.7.1 and the Atahualpa WordPress theme, the WordPress RSS widget needs to be activated and positioned above it. That’s how I temporarily solved my problem, until (if ever) I have the time to look deeper into the code involved or newer versions of  the theme and/or the plugin solve it for good.

Just to be clear, none of the problems and troubleshooting it took to solve them can be traced back ato KB Advanced RSS alone. Atahualpa is a great but complex theme and it is their combination that turned out to be problematic. It’s not the first example of a bad mix and it won’t be the last. On the flip side, with each such incident we get to learn something new that will potentially save others and ourselves some frusrtation and time in the future.

6 comments to WordPress: External RSS Feeds Optimization with KB Advanced RSS

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>