我知道向自定义帖子类型帖子添加自定义字段(元框)很容易。我还知道,如果你想给帖子类型添加缩略图,你应该在register_post_type
. 但如何使用自定义帖子类型本身(归档)?
PS:我已经阅读了register_post_type
但什么也没找到。https://codex.wordpress.org/Function_Reference/register_post_type
我知道向自定义帖子类型帖子添加自定义字段(元框)很容易。我还知道,如果你想给帖子类型添加缩略图,你应该在register_post_type
. 但如何使用自定义帖子类型本身(归档)?
PS:我已经阅读了register_post_type
但什么也没找到。https://codex.wordpress.org/Function_Reference/register_post_type
你是说这样的事吗?
$args = array( \'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'menu_position\' => null,
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'comments\' )
);
此代码位于创建CPT的函数之后,register\\u post\\u类型之前i、 e。
function my_custom_post () {
...
}
$args = array (...)
);
register_post_type ($cpt, $args);
存档本身不是使用register\\u post\\u type()函数定义的,它们只是使用主题的存档页或自定义存档页格式显示或列出给定的帖子类型。缩略图或特色图像的显示由主题或自定义存档页控制。
如果注册了CPT以支持类别,则可以为自定义帖子类型的给定类别定义缩略图或特征图像。但该类别缩略图的显示同样由主题或自定义存档页面决定。不在CPT内部。
我在函数末尾添加以下代码。php文件,用于根据自定义帖子的帖子标题填充分类法。问题是,当我添加代码时,尝试登录wp admin时会出现以下错误。非常感谢您能帮助我们弄清楚为什么会发生这种情况。Error:错误:由于意外输出,Cookie被阻止。有关帮助,请参阅此文档或尝试支持论坛。Code: <?php function update_custom_terms($post_id) { // only update terms if