Solved following way: Disabled the framework and enabled it again. It works :)
Single page template not working for custom post type
-
14-07-2023 - |
Vra
I have 3 different type of custom post types and using Redux framework. All are working but facing two problem. If i unset the framework, it works fine.
the_permalink()
is missing post_type in URL like following: should behttp://sitename/product/abc
but gettinghttp://sitename/abc
. and it takes me to 404 page.(In product edit screen i got correct slug, but not withthe_permalink()
)When i correct the url manually (
http://sitename/product/abc
), it takes me to homepage. But it should be in single-product.php or single.php page.
I used following code to make Custom post type:
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();
}
I am running WordPress 3.9
and Redux 3.2.0
without dev_mode
enabled.
My permalink structure: /%postname%/
Please let me know, if it can be solved.
Thanks in advance.
Oplossing