简体   繁体   中英

Using shortcodes in php in wordpress

I am trying to use shortcodes in my php template in wordpress and using the following code does not work. Please help:

<?php
 $args = array('post_type' => 'package', 'package-category' => 'South Africa',     'posts_per_page' => 6);
 $loop = new WP_Query($args);
 while($loop->have_posts()) : $loop->the_post();

$thumbnail = get_the_post_thumbnail();

$mc_content = <<<MCC
<div class="four columns gdl-package-grid2">
    <div class="package-content-wrapper">
        $thumbnail
    </div>
</div>
MCC;


echo do_shortcode('[tab_item title="ITEM_TITLE"]' .$mc_content. '[/tab_item]');



endwhile;
?>

Have you tried this ?

This may be help.

echo do_shortcode('[tab_item title="ITEM_TITLE"]' .addslashes($mc_content). '[/tab_item]');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM