【问题标题】:Display which Wordpress template and template_part files are used to construct a page?显示哪些 Wordpress 模板和 template_part 文件用于构建页面?
【发布时间】:2016-11-17 20:45:27
【问题描述】:

尝试使用 JetPack 的投资组合自定义内容类型和下划线投资组合组件,但不能完全确定是否正在加载正确的模板。

是否有配置或插件会在浏览器中显示哪些 Wordpress 模板和 template_part 文件用于构建页面?

【问题讨论】:

    标签: wordpress templates


    【解决方案1】:

    试试

    <?php echo '<!-- ' . basename( get_page_template() ) . ' -->'; ?>

    在你的footer.php

    使用get_page_template 将模板的名称转储到注释标记中 - <!----> - 因此它在源代码中可见,但对前端查看者不可见。

    或者使用

    <?php get_current_template( true ); ?>
    

    如果您希望它在前端完全可见。

    https://developer.wordpress.org/reference/functions/is_page_template/

    有一个提供该功能的插件:https://wordpress.org/plugins/reveal-template/ 而这个提供该功能和许多其他调试信息的插件:https://wordpress.org/plugins/debug-bar/

    【讨论】:

      猜你喜欢
      • 2012-05-07
      • 2018-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-13
      相关资源
      最近更新 更多