Wordpress theming 循环后Wordpress do_短码函数的实现
我正在做一个关于wordpress主题的项目。Wordpress有一个函数调用do_shortcode,但当我实现它时,代码不起作用。$metagallery的输出是 [Best_Wordpress_Gallery id=“1”gal_title=“Gallery 1”] 为什么当我使用函数do_shortcode回音时它不工作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
<?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="1" gal_title="Gallery 1"]
双引号将更改为特殊字符。因此必须对其进行解码。
通过应用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”]”那样使用它是否有效代码>?当我用那种方式时,它就起作用了。