Support » Fixing WordPress » Filter for sidebar

  • I was looking for an hook for sidebar but I haven’t found anything. Is it possible to hook sidebar output to provide plugin for it? I would like to write a plugin for sidebar to allow dynamically append html to it without modifying sidebar template. Suggestions are welcome.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator James Huff

    (@macmanx)

    Halfelf Minion 🚀

    There is wp_meta:
    Parameter unused. Executes in the Meta section of the included Theme’s sidebar.php’s. Useful for insertion of additional content.

    I have tried in the following way and of course doesn’t work.

    function myplugin($input) {
    $output=$input.”Hello world!”;
    return $output;
    }

    add_filter(‘wp_meta’, ‘myplugin’,0);

    Moderator James Huff

    (@macmanx)

    Halfelf Minion 🚀

    Well, there are plenty of plugins which add content to the sidebar. RecentPosts, RecentComments, and CG-FeedReader come to mind. Do a search for those and dissect them. They all involve adding a PHP query string to the sidebar.

    As wp_meta is an action defined in wp-includes/template-functions-general.php:
    56 function wp_meta() {
    57 do_action(‘wp_meta’);
    58 }

    Modifying my test code in the following way works:

    function myplugin() {
    $output=”Hello world!”;
    echo $output;
    }

    add_filter(‘wp_meta’, ‘myplugin’,0);

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Filter for sidebar’ is closed to new replies.