Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress theming 循环后Wordpress do_短码函数的实现_Wordpress Theming_Wordpress - Fatal编程技术网

Wordpress theming 循环后Wordpress do_短码函数的实现

Wordpress theming 循环后Wordpress do_短码函数的实现,wordpress-theming,wordpress,Wordpress Theming,Wordpress,我正在做一个关于wordpress主题的项目。Wordpress有一个函数调用do_shortcode,但当我实现它时,代码不起作用。$metagallery的输出是 [Best_Wordpress_Gallery id=“1”gal_title=“Gallery 1”] 为什么当我使用函数do_shortcode回音时它不工作 <?php $metagallery = get_post_meta($id, '_jdev_custom_meta', true); ?> <?p

我正在做一个关于wordpress主题的项目。Wordpress有一个函数调用do_shortcode,但当我实现它时,代码不起作用。$metagallery的输出是 [Best_Wordpress_Gallery id=“1”gal_title=“Gallery 1”]

为什么当我使用函数do_shortcode回音时它不工作

<?php 
$metagallery = get_post_meta($id, '_jdev_custom_meta', true);
?>
<?php if ($metagallery!="") { ?>
<div class="row clearfix galleryarea" >
    <div class="col-md-10 col-md-offset-1 column">
        <div class="row clearfix" >
            <div class="col-md-12 column">
                <div class="gallerycontent">

                        <h2>Gallery</h2>
                        <?php 


                        echo do_shortcode($metagallery); ?>

                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php } ?>

画廊

好的。解决了。在html中查看时,它是:

[Best_Wordpress_Gallery id="1" gal_title="Gallery 1"]
但在源代码中查看时,它看起来是这样的:

[Best_Wordpress_Gallery id=&quot;1&quot; gal_title=&quot;Gallery 1&quot;]
双引号将更改为特殊字符。因此必须对其进行解码。 通过应用htmlspecialchars\u解码,它解决了这个问题

<?php echo do_shortcode((htmlspecialchars_decode($metagallery))); ?>


使用
$metagallery
的结果是什么?如果将其像
echo do_shortcode('.$metagallery')那样包装,会产生什么结果?完全没有输出。哈哈。我正在使用照片库$metagallery的输出是[Best_Wordpress_gallery id=“1”gal_title=“gallery 1”]如果像
echo do_快捷码(“[Best_Wordpress_gallery id=“1”gal_title=“gallery 1”]”那样使用它是否有效?当我用那种方式时,它就起作用了。