Using Shortcode in WordPress Post Excerpts

Shortcodes do not work in WordPress post excerpts by default, but you can easily make your post excerpts shortcode compatible by using the function described in this post.

Shortcodes were introduced in WP version 2.5 primarily for use in post content. They were not meant for post excerpts nevertheless you can easily add the shortcode capability to your post’s excerpts.

To add the shortcode functionality to WordPress excerpts , hook your custom function to ‘get_the_excerpt’ filter in following way:

 

The above code allows you to add your custom shortcodes into post excerpts. The code will work with all those excerpts which are manually added to posts.

  • THANK YOU!!!! WOW!! I have been searching for this for a while now. You have just made my month with this post. YOU ARE AMAZING!

    • Fiaz Husyn

      Glad to know that it helped you. Have happy coding!

  • Thank you so much! Amazing that this was otherwise so difficult to find; appreciate your sharing this