【发布时间】:2017-02-01 04:50:09
【问题描述】:
我有 aj-fashions 自定义帖子类型。从技术上讲,我试图在名为 fashio-template.php 的模板文件中显示所有帖子的循环,现在对于单个帖子,我创建了文件 single-fashions.php。我仍然收到找不到页面的 404 错误。
请指教,以下是我的代码。
add_action( 'init', 'fashion' );
function fashion() {
register_post_type( 'aj-fashion',
array(
'labels' => array(
'name' => __( 'AJ Fasions' ),
'singular_name' => __( 'AJ Fashion' )
),
'public' => true,
'has_archive' => true,
'show_ui' => true,
'hierarchical' => false,
'rewrite' => array('slug' => 'aj-fashions',),
'supports'=> array( 'title', 'editor', 'thumbnail', 'author' ),
)
);
}
【问题讨论】:
-
添加flush_rewrite_rules();工作。
-
什么是单个帖子特定的帖子循环???
-
从设置更新永久链接。
-
它工作了我在永久链接中添加了帖子 $post->ID 并且它的工作......谢谢大家......
标签: php wordpress custom-post-type