WordPress.org

Ready to get started?Download WordPress

Forums

Widgetizing the BDP RSS Aggregator Plugin (3 posts)

  1. SavoryMedia
    Member
    Posted 8 years ago #

    I installed the new Widgets plugin from Automattic and was trying to figure out how to turn output from the BDP RSS Aggregator plugin into a widget for use in the sidebar.

    After reading all the Widgets documentation (especaially about widgetizing plugins) I tweaked out the following code and it works perfectly:

    <?php
    function widget_bdprss2_1($args) {
    extract($args);
    ?>
    <?php echo $before_widget; ?>
    <?php echo $before_title
    . 'Syndicated News'
    . $after_title; ?>
    <?php BDPRSS2::output(1); ?>
    <?php echo $after_widget; ?>
    <?php
    }
    register_sidebar_widget('Syndicated News',
    'widget_bdprss2_1');
    ?>

    To use the code, just drop it as is into your theme's functions.php file. (And, of course, have the BDPRSS2 plugin installed and configured to use channel 1's output...and the Widgets plugin installed and your sidebar.php and functions.php updated.)

    If you want to use multiple widgets, just change the channel in <?php BDPRSS2::output(1); ?> from 1 to 2 (or 3 or 4, etc.) depending on how many you want to use...and change the 1 in widget_bdprss2_1 to match the channel you specified in the output code (this is just to keep everything organized). Changing "Syndicated News" to match the feed output on each would also be prudent.

    Anyway. I thought this was nifty...and it being one of my first attempts at (semi)custom coding (that actually works), I decided to share it.

    Hope you find it useful!

  2. frankpereiro
    Member
    Posted 8 years ago #

    Thanks for sharing this with us, Media. I will try it and then let you know about it.

    Greetz,

  3. davidchait
    Member
    Posted 8 years ago #

    Yep, cool.

    Any plugin that already does a function call for output can pretty simply be thrown into a widget. I plan to have them for CG-Amazon, CG-FeedRead, CG-Referrer, etc., but anyone with a little PHP knowledge can do exactly what you did with BDP. Good for folks to see an example, as they can go and build widgets as needed, for pretty much any plugin or code library...

Topic Closed

This topic has been closed to new replies.

About this Topic