How can I enable shortcodes on a custom post type that doesn't use the_content() or get_the_content()? In the template file it uses

<?php echo nl2br( $post->post_content ); ?>

to get the content from the backend like any other post or page would. I have tried using

<?php echo do_shortcode(get_post_field('post_content', $postid)); ?>

which works but the shortcode itself is still displaying for example:

[gallery columns="4" link="file" ids="1,2,3,4"]

displays above the gallery photos.

  • 1
    And why doesn’t it use the_content? Jul 1, 2018 at 6:04
  • I do not know why it doesn't use the_content. This is a plugin from WordPress Repository - All In One Video Gallery.
    – Peter
    Jul 2, 2018 at 6:20
  • Then the plugin appears to have been built in such a way that doesn't support shortcodes. You will need to check with the author if there's a workaround. Jul 2, 2018 at 11:26

4 Answers 4


I had similar problem because I was rendering content like this:

echo get_the_content();

Instead of:


The 2nd function must include the shortcode filter.


Shortcodes really should run in custom post types. Essentially a custom post type is a post. So it sounds like there is a problem filtering shortcodes somewhere.

What is likely happening is that you are using get_the_content() rather than the_content() which doesn't filter. Where and how are you displaying the content for the custom post type?

If this is the case, please use get_the_content() function in this way to apply appropriate filtering.

<?php apply_filters('the_content',get_the_content( $more_link_text, 
 $stripteaser, $more_file )) ?>

Visit this link for more detail about your Problem


  • I had already tried that from wpmudev and that did not work either. The plugin author is fixing this issue in the next update. Like I said earlier, For my particular situation the answer was to replace <?php echo nl2br( $post->post_content ); ?> with <?php echo $content; ?> which allowed all shortcodes to work as expected.
    – Peter
    Jul 3, 2018 at 19:14
  • Thanks this helped me.
    – CJWEB
    Mar 6, 2020 at 0:00

Use apply_filters() to let WordPress process the shortcodes in your content.

<?php echo apply_filters('the_content', $post->post_content); ?>

  • This did not work. I got a blank page when using this which said the connection had been reset.
    – Peter
    Jul 2, 2018 at 6:21
  • Try passing the result from nl2br( $post->post_content ) through apply_filters(): <?php echo apply_filters('the_content', nl2br( $post->post_content ) ); ?> and see what happens.
    – Peter HvD
    Jul 2, 2018 at 15:42
  • No, that did not work either. Same result. I did try <?php echo $content; ?> in place of <?php echo nl2br( $post->post_content ); ?> and the shortcodes are now displaying as expected. Thanks
    – Peter
    Jul 2, 2018 at 16:27

For my particular situation the answer was to replace <?php echo nl2br( $post->post_content ); ?> with <?php echo $content; ?> which allowed all shortcodes to work as expected.

  • You modified the plugin directly? Jul 2, 2018 at 16:58
  • Yes, I modified the plugin directly in one of it's template files.
    – Peter
    Jul 3, 2018 at 19:11
  • The change is going to be erased whenever you update the plugin then. Jul 4, 2018 at 0:07
  • Wow. Yes I know that. LOL That's why I save files that have been changed.
    – Peter
    Jul 5, 2018 at 6:12

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.