How to allow shortcodes in WordPress comments

Shortcodes in Comments

WordPress comments as far as I know don't render shortcodes.

If your theme use custom shortcodes you can't use them in comments. Also, with the new video and audio support for WordPress 3.6 you can not use them in comments.

Simply add this line to your functions.php of your theme and now shortcodes will be correctly rendered within comments.

add_filter( 'comment_text', 'do_shortcode' );
Code language: JavaScript (javascript)

Shortcodes in Widgets

Yes, following the same principle you'll need to add a new filter to the functions.php file.

Try it first, put a shortcode in a text widget, your theme might already have this line. If the shortcode doesn't work, then paste the following snippet:

add_filter( 'widget_text', 'do_shortcode' );
Code language: JavaScript (javascript)

Shortcodes in Excerpt

Yep. Even though I wouldn't recommend it. You see, I usually use this field for SEO purposes so I won't use any shortcodes in it.

However, if you need it, here it is:

add_filter( 'the_excerpt', 'do_shortcode');
Code language: JavaScript (javascript)
  • Hi,

    Could you please inform us about the way to allow shortcodes in wordpress search results?


    • Hi Tom,

      Do you mean when you use the WordPress search?

      Well, that should be within the search.php file of your theme. If the theme prints the whole post, an excerpt or just the title.

      I’m not sure it’s something you can turn on from the functions.php file (like the examples above).

  • ¡Hola Rick!

    Edu plugin es excelente pero me encantarĂ­a que en el plug in tambiĂ©n pudiĂ©ramos ordenar las entradas ya sea “Con más pulgares arriba” y “más pulgares abajo”. Creo que ayudarĂ­a a muchos blogs a generar competitividad entre sus autores.

    ¿Qué opinas?

  • Hi Ricard,

    I’ve tried adding many [thumbs-rating-buttons] in a single post or 1 post about 20 [thumbs-rating-buttons] and when I test it the results were the same on all Thumbs Rating in a single post or content. Any idea how do I do this? Thanks in advance

    • Hey Mike,

      Sorry for the late response, your comment fell into the spam folder.

      Not sure I get your issue. You have to consider the thumbs-rating plugin I wrote ( ) has to be linked to a single post or content.

      You can not add multiple buttons on the same post and expect the user to vote diferent things. Each button has to be linked to a post or custom post type.

      Let me know if this helps.


  • Hi, Same basic question. Is there a way to pass in a postID to the shortcode? I have a list of CPT results on a page and i need a way to have thumbs up/down on each one with AJAX updates. If there is a way to pass in the postID then i can use it in the loop.

  • Hey Tom,

    For anyone reading this, the context is this plugin

    At this moment, for the current version, there’s no way to pass the post ID to the buttons shortcode.

    Best regards.

  • Would this be something you could add easily or do i need to build something myself? I have to launch this feature soon.

    • Tom

      I have no time to add new features. The plugin is stable enough and rather super simple.

      Have you considered a more robust/complete rating plugin?


  • Hi Rick, is add_filter( ‘comment_text’, ‘do_shortcode’ ); secure for a website?

Leave a Reply

Add <code> Some Code </code> by using this tags.