Wordpress 单页模板不适用于自定义帖子类型
我有3种不同类型的自定义帖子类型,并使用Redux框架。他们都在工作,但面临两个问题。如果我取消设置框架,它可以正常工作 URL中缺少帖子类型,\u permalink,如下所示: 应该是http://sitename/product/abc 但是http://sitename/abc. 它把我带到了404页。在产品编辑屏幕上,我得到了正确的slug,但并没有使用_permalink 当我手动更正url时http://sitename/product/abc,它把我带到主页。但它应该在single-product.php或single.php页面中 我使用以下代码创建自定义帖子类型:Wordpress 单页模板不适用于自定义帖子类型,wordpress,url-rewriting,wordpress-theming,hierarchy,custom-post-type,Wordpress,Url Rewriting,Wordpress Theming,Hierarchy,Custom Post Type,我有3种不同类型的自定义帖子类型,并使用Redux框架。他们都在工作,但面临两个问题。如果我取消设置框架,它可以正常工作 URL中缺少帖子类型,\u permalink,如下所示: 应该是http://sitename/product/abc 但是http://sitename/abc. 它把我带到了404页。在产品编辑屏幕上,我得到了正确的slug,但并没有使用_permalink 当我手动更正url时http://sitename/product/abc,它把我带到主页。但它应该在singl
add_action( 'init', 'tormuz_product_cpt' );
function tormuz_product_cpt() {
$labels = array(
'name' => _x( 'Products', 'post type general name' ),
'singular_name' => _x( 'Product', 'post type singular name' ),
'add_new' => _x( 'Add New', 'book' ),
'add_new_item' => __( 'Add New Product' ),
'edit_item' => __( 'Edit Product' ),
'new_item' => __( 'New Product' ),
'all_items' => __( 'All Products' ),
'view_item' => __( 'View Product' ),
'search_items' => __( 'Search Products' ),
'not_found' => __( 'No products found' ),
'not_found_in_trash' => __( 'No products found in the Trash' ),
'parent_item_colon' => '',
'menu_name' => 'Products'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our products and product specific data',
'public' => true,
'menu_position' => 45,
'supports' => array( 'title', 'editor', 'thumbnail' ),
'has_archive' => true,
);
register_post_type( 'product', $args );
flush_rewrite_rules();
}
我正在运行WordPress 3.9和Redux 3.2.0,但没有启用开发模式
我的永久链接结构:/%postname%/
如果可以解决,请告诉我
提前感谢。通过以下方式解决:
已禁用该框架并再次启用它。它可以工作:只是需要刷新你的URL缓存吗?呵呵。