0
所有文章我已经创建了一个自定义后型“产品”,它表现为在仪表盘上单独的一类“产品”。我正在按照关于如何编辑自定义帖子的一些说明,它告诉我通过posts->所有帖子对它们进行编辑,以便我可以将自定义字段作为屏幕视图的一部分,但是我没有看到我的任何实例访问“所有帖子”时发布的“产品”信息。所有帖子 - 定制和标准 - 应该出现在所有帖子下?当我设置“产品”帖子时,我做错了什么?自定义信息没有出现在帖子 - >在管理菜单
<?php
function create_product_post_type() {
$labels = array(
'name' => 'Products',
'singular_name' => 'Product'
);
$args = array(
'labels' => $labels,
'public' => true,
'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'comments'),
'taxonomies' => array('category')
);
register_post_type('product', $args);
}
add_action('init', 'create_product_post_type');
function add_product_to_archives($wp_query) {
$types_array = array('post', 'product');
if(is_category() || is_tag() && empty($query->query_vars['suppress_filters'])) {
set_query_var('post_type', $types_array);
}
}
add_action('pre_get_posts', 'add_product_to_archives');
?>
号自定义职位不应该在“帖子” =>“所有文章”出现。您的产品自定义帖子应该出现在“产品”=>“所有产品”下,这就是您可以添加,编辑等的位置。我相信您错误地使用了“类别”一词:'....显示为一个分类在仪表板中......“ - 您可能的意思是它在仪表板菜单中显示为单独的*菜单项*。这是它应该显示的地方。 –