0

I want to add a shortcode tag in the sidebar/widget.

I am able to get the required functionality if I add the code in the theme's function.php

add_filter('widget_text', 'do_shortcode');

My problem is that I am searching for a way I can do this from the plugins files itself without affecting any of the theme files.

Can anyone tell me if this is possible?

1
  • Add the line to your child themes functions file Feb 21, 2014 at 0:23

2 Answers 2

1

Here is your plugin:

<?php
/*
Plugin Name: Do shortcode in side-widget
Description: Let's do it.
Version: 0.1
Author: CyberPanda
*/

add_filter('widget_text', 'do_shortcode');
?>
0
1

This should be pretty easy. Just create a plugin http://codex.wordpress.org/Writing_a_Plugin#Standard_Plugin_Information

and put your function code there. The only risk is that it can be accidentally deactivated by users with relevant privelages.

3
  • I have created a plugin. How do I add this code in the plugin is my question. Feb 19, 2014 at 10:23
  • @molokom Please explain how much you can instead of providing external links :)
    – sri
    Feb 19, 2014 at 10:37
  • 1
    @sri ok. I thought link to the codex were ok. I'll do better next time.
    – molokom
    Feb 19, 2014 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.