【问题标题】:ShortCode doesn't work when I use custom template in wordpress当我在 wordpress 中使用自定义模板时,ShortCode 不起作用
【发布时间】:2017-07-13 14:25:00
【问题描述】:

我创建了自定义模板“contact.php”

contact template
 <?php if (have_posts()) : while (have_posts()) : the_post();?>
  <?php the_content(); ?>
 <?php endwhile; endif; ?>

我创建了一个名为contact的页面,内容中只有一个短代码

[wpgmza id="1"]

我将此页面的模板设置为联系 但我在真实网页中看不到简码,也不知道原因。 我试图在模板中调用 do_shortcode('[wpgmza id="1"]') 但它也不起作用。 任何建议都会有很大帮助。 谢谢:)

【问题讨论】:

    标签: wordpress templates shortcode


    【解决方案1】:

    您可能需要添加回声。参考:https://developer.wordpress.org/reference/functions/do_shortcode/

    echo do_shortcode( '[wpgmza id="1"]' );

    【讨论】:

      猜你喜欢
      • 2013-11-10
      • 2014-01-25
      • 1970-01-01
      • 2023-03-24
      • 2011-09-30
      • 2021-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多