【问题标题】:template management with wordpress (underscore boilerplate)使用 wordpress 进行模板管理(下划线样板文件)
【发布时间】:2022-11-26 08:07:03
【问题描述】:

我正在使用 underscore 开发一个 wordpress 主题。

我有一个自定义帖子类型名称project,因此我有,例如,这个 url:http://a.site.local/projects/a-beauty/

我的template-parts/ 目录中有文件content-projects

$ cat template-parts/content-projects.php 
<h1>Project</h1>

当我浏览http://a.site.local/projects/a-beauty/时,我有我的标题还有侧边栏和页脚(即使它们没有出现在我的content-project.phpindex.php 中)。

这些小部件从哪里来/从哪里加载?

【问题讨论】:

标签: wordpress templates wordpress-theming


【解决方案1】:

请从您的项目中分享更多代码,以便我们轻松理解真正的问题。

【讨论】:

    【解决方案2】:

    向页眉、页脚和侧边栏添加条件。

    对于整个自定义帖子存档:

    <?php if( !is_post_type_archive( 'project' ) ) : ?>
        // wrap the code you don't want to show on that archive
    <?php endif; ?>
    

    仅适用于自定义帖子:

    <?php if( !is_singular( 'project' ) ) : ?>
        // wrap the code you don't want to show on the post
    <?php endif; ?>
    

    如果您想放置要显示的代码,请删除“!”条件前。

    附言 您可以将整个内容放在一个条件下,但保留

    </div><!-- #page -->
    <?php wp_footer(); ?>
    </body>
    </html>
    

    否则页面会中断:)

    【讨论】:

      猜你喜欢
      • 2012-10-03
      • 1970-01-01
      • 1970-01-01
      • 2012-08-20
      • 2013-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多