Connect with us

Solved – WordPress short code not working with post_content


Solved – WordPress short code not working with post_content

I am continuously working with WordPress since last few years. In one of my project, my client was facing a problem with short code. My Client uploads an image and add Caption. Caption is added and it looks fine with WP Editor. But when he view that page in front end, it shows short code itself instead of real converted short code html. I searched for the same and found that short code works with the_content or get_the_content. I used $post->post_content for custom post type. This means WordPress Short code not working with post_content.

To solve this and convert short codes, you just need to write below code. You need to use the_content() function which convert short codes automatically.

if( have_posts() ) {
  while (have_posts()) : the_post();

If you are unable to write such code and wanted to convert short codes, than you can also use below function.

<?php do_shortcode('[shortcode_here]');?>
For e.g.
<?php do_shortcode('[contact-form-7 404 "Not Found"]');?>

Using this function, you can convert short code manually. Let me know if you are facing any problem with this.

Continue Reading
Click to comment

Leave a Reply

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

More in coding

About Me:

Szabi Kisded

Hey there, I'm Szabi. At 30 years old, I quit my IT job and started my own business and became a full time WordPress plugin developer, blogger and stay-at-home dad. Here I'm documenting my journey earning an online (semi)passive income. Read more

Sign up for my newsletter and get the YouTube Caption Scraper WordPress plugin for free
(worth 29$)!

All My Plugins In A Bundle:

My AutoBlogging Plugins:

My Online Courses:

A Theme I Recommend:

Featured Posts:

To Top