Widgetizing plugins - popularity code & wordpress

view a random?

I added a little PHP to my Popularity plugin to allow me to plug it into this here Theme without needing to edit the Sidebar.php - which wouldn’t be an issue (this time) but I’ve changed theme 3 times today - so enough is enough!

// Widget stuff
function widget_most_pop_register() {
    if ( function_exists('register_sidebar_widget') ) :
    function widget_akpc_pop($args) {
        extract($args);
        echo $before_widget;
        echo $before_title . 'Most Popular Posts'. $after_title;
        ?><ul>
       <?php akpc_most_popular(); ?>
       </ul><?php
        echo $after_widget;
    }

    register_sidebar_widget('Popularity', 'widget_akpc_pop',
     null, 'most popular');
    endif;
}

add_action('init', 'widget_most_pop_register');

Widgetizing Plugins gives an example of how to do this with other plugins. If you want to find the popularity plugin, you can just follow the little question marks on all of my posts. It is a good plugin, though it doesn’t really report raw hits, you do get a good idea of which of your posts are worth their salt.

Here is another website on creating widgets for Wordpress.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • MisterWong
  • Reddit
  • Scoopit
  • StumbleUpon
  • Technorati
  • rss

One Trackback

  1. By Anonymous on February 12, 2008 at 3:59 pm

    Widgetizing plugins - popularity code & wordpress…

    I added a little PHP to my Popularity plugin to allow me to plug it into this here Theme without needing to edit the Sidebar.php - which wouldn’t be an issue (this time) but I’ve changed theme 3 times today - so enough is enough!…

Post a Comment

You must be logged in to post a comment.