Connect with us

Solved – WordPress short code not working with post_content

coding

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.

<?php
if( have_posts() ) {
  while (have_posts()) : the_post();
    the_content();
  endwhile;
}
?>

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.

No votes yet.
Please wait...
READ  Online Tips To Find Out The Best WordPress Theme
Continue Reading
You may also like...

We are a WordPress plugin developer company that focuses on useful WordPress plugin creation and empowering people to earn passive incomes from their blogs. We build unique and groundbreaking plugins that will revolutionize your blog!

Click to comment

Leave a Reply

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

More in coding

Sign up for our newsletter and get a free affiliate e-book!


About Me:

Szabi Kisded

Hi, my name is Szabi and I'm documenting my journey selling plugins on CodeCanyon. I will show you every step of it: learning to code, plugin ideas, WordPress stuff and more. Read more…

Mega Plugin Bundle:

CodeCanyon Portfolio:

Learn to Code Plugins:

Latest Promotions:

Recommended Theme:

Start Your Own Blog:

Recommended VPN Service:

Translate Your Blog:

AdSense Alternative:

Best Article Spinner:

Popular Posts:

Latest Posts:

To Top

Privacy Preference Center

      Necessary

      Advertising

      Analytics

      Other