1

At the moment, I'm running WordPress v3.2.2 (soon to upgrade to v3.4.2), and am trying to insert shortcode to insert Issuu into a text widget on our sidebar. The WordPress plugin I installed and am trying to use is WP Issuu, where it says I simply need to take the embed shortcode off of the article and insert it into any post or page on the site. The shortcode works on the pages and posts, which means the widget on the website is working.

I've looked at a couple of links, including this link, which told me I had to simply insert this code into the function.php file and the shortcode would be read:

add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode');

Instead of showing the viewer in the sidebar, the shortcode is showing on the screen as text like the picture below:

shortcode showing instead of actual Issuu viewer

On this post: Inserting shortcode [stream /] into a Text widget, I saw he had a similar problem but instead tried to insert the <?php ?> tag around the shortcode, looking like below, which didn't work either:

<?php echo do_shortcode('[issuu width=100 height=100 backgroundColor=%23222222 documentId=121205060625-55b37366f5bb447998a5683f7b7ec9af name=di12052012 username=thedailyillini tag=news unit=%]'); ?>

I don't want to resort to another plugin, such as this one to read in the PHP and want to add a simple PHP function to enable the shortcode to be read into the text widget with the code above. Is there another resort beside the add_filter code that could work? Or does this have to do with the version of WordPress being used?

3
  • I assume [issuu] is no shortcode; what plugin are you using?
    – Michael
    Commented Dec 6, 2012 at 18:51
  • I'm sorry I should've specified and edited on the initial post, but I'm using wordpress.org/extend/plugins/wp-issuu
    – Abriel
    Commented Dec 6, 2012 at 18:53
  • the plugin does not use shortcode. if you want to run this in the sidebar, you will either need to use a php code widget, or hardcode it.
    – Michael
    Commented Dec 6, 2012 at 20:30

1 Answer 1

1

To run php codes from inside widgets there's other plugin for it: WP widget to contain PHP

Though the use of php code in widgets is not recommended.

8
  • I definitely don't want to run PHP code in the widgets.. I would like to be able to use shortcodes to run in the widget. Is there a possible way to do this besides the attempts I tried in my post?
    – Abriel
    Commented Dec 6, 2012 at 19:29
  • Of course there is, if you please describe the way you have tried step by step then we can be assured you are at the right path. Paste in sample codes. It would be a nicer idea to host your code in github as openSource, which can just be sample code. So people can show you exactly what you are missing out.
    – Lenin
    Commented Dec 7, 2012 at 17:47
  • I made edits to my original post. Hopefully this helps you understand a bit better. If not, definitely let me know!
    – Abriel
    Commented Dec 7, 2012 at 18:32
  • Try this: link
    – Lenin
    Commented Dec 7, 2012 at 21:25
  • 2
    Simply, adding the add_filter('widget_text', 'do_shortcode'); would enable your text widgets to parse the shortcodes.
    – Lenin
    Commented Dec 7, 2012 at 21:29

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.