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)


  1. Tim G. says:

    Just wanted to say thanks for the code!

    1. You’re welcome, Tim!

  2. Jose Orozco says:

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

    1. Hey Jose,

      I don’t see why not. In the end you as the site owner have the power to restrict, add or remove functionality.

      Sure, perhaps you have a plugin that shows sensitive information via shortcodes. Enabling shortcodes in comments means someone could potentially output information you don’t want.

      There are 2 other filters that perhaps help with your concerns:

      Best regards

  3. Tom says:

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

    1. 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?


  4. 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.

  5. Tom says:

    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.

  6. Mike says:

    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

    1. 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.


  7. Servando says:

    ¡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?

    1. Rick says:


      Si hablas del Thumbs Rating plugin, ya lo hace.

      Mira el FAQ, al final tienes el shortcode que genera listas en base a parámetros:

      Un saludo.

  8. Tom says:


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


    1. Rick says:

      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).

Leave a Reply

Your email address will not be published. Required fields are marked *