【发布时间】:2015-12-15 23:15:50
【问题描述】:
我在 WordPress 中创建了一个自定义帖子类型,并且我还将其单独的两个页面设置为 single-acme_product.php、archive-acme_product.php 但问题是当我从自定义帖子类型上传帖子时,它的显示 index.php
这是我的函数代码
function new_post_type_wp(){
register_post_type('acme_product',
array(
'labels' => array(
'name' => __('Products'),
'singular_name' => __('Product')
),
'public' => true,
'has_archive' => true,
)
);
}
add_action('init','new_post_type_wp');
请告诉我如何将我的自定义帖子导航到特定的自定义页面
【问题讨论】:
-
Usman 不清楚您面临什么问题。能否请您添加更多信息。
-
亲爱的,我创建了一个自定义帖子类型,我只想在 single-acme_product.php 上显示我的自定义帖子,这个问题我为自定义帖子参考链接 @987654322 创建了一个单独的页面 single-acme_product.php @ 但是帖子显示在 single-acme_product.php 他们显示在 index.php 我只想在我的 single-acme_product.php 上显示这些帖子你明白了吗??
-
是的,我收到了,感谢您提供更多信息。您的自定义帖子类型不应出现在 index.php 上。请使用此链接生成 cpt 代码 themergency.com/generators/wordpress-custom-post-types 并确保您设置了重写选项,以便您的自定义帖子类型可在 /cpt/single-item-name
-
亲爱的我的cpt代码是完美的,但是cpt的帖子不能导航single-spt.php并且您发送它的链接也会生成cpt,我只需要cpt帖子导航到single-cpt。 php
-
转到wordpress仪表板,设置->永久链接然后保存(无需更改选项)。然后尝试,如果不让我知道还有另一件事要尝试
标签: wordpress wordpress-theming custom-post-type