所以我的主题有一个标签。php,其中包含以下行:
get_template_part(\'loop\',\'tag\');
get_template_part()
正在吐。我知道我应该能够通过创建自己的循环中循环标记来实现这一点。php或类似的东西,但找不到示例。有人能给我一个简单的循环标记示例吗。会破坏get_template_part(\'loop\',\'tag\')
进入it组件?
所以我的主题有一个标签。php,其中包含以下行:
get_template_part(\'loop\',\'tag\');
get_template_part()
正在吐。我知道我应该能够通过创建自己的循环中循环标记来实现这一点。php或类似的东西,但找不到示例。有人能给我一个简单的循环标记示例吗。会破坏get_template_part(\'loop\',\'tag\')
进入it组件?
我想你误解了这个计划的目的get_template_part()
. 它是locate_template()
, 它本身只是include()
.
通过调用get_template_part( \'loop\', \'tag\' )
, 您正在告诉WordPress根据以下优先级查找/包含文件:
子主题loop-tag.php
loop-tag.phploop.phploop.php
If you need to modify the markup of the loop itself, then you simply need to modify the appropriate file, according to the above priority list - e.g. loop-tag.php
in your Theme or Child Theme.
loop.php
, 命名副本loop-tag.php
, 并根据需要进行编辑。最简单的方法是找到循环,在您的情况下,它看起来像是在一个名为loop.php
.
制作标签的备份副本。php删除get_template_part(\'loop\',\'tag\');
来自标记。php复制/粘贴循环的内容。php转换为标记。php
注意:如果有问题,请确保没有从标记中删除页眉和页脚调用或任何其他标记。php(或loop.php),下次粘贴整个标记时。php代码。
我已设置为使用标准之外的post格式库和视频。我正在编辑循环单。php为每个帖子格式提供不同的布局,但我要为每个帖子格式包含get\\u template\\u部分。这就是我所拥有的:<?php /** * The loop that displays a single post. * * The loop displays the posts and the post content. See * http://codex.wordpress.or