I dont know why my custom post types render the Page not found. This is the code I am using to register custom posts.

www.example.com/products/product1/ renders 404 where as www.example.com/?products=product1 is perfectly fine.

add_action( 'init', 'create_post_type' );
function create_post_type() {
    register_post_type('products', array(
        'label' => __('Products'),
        'singular_label' => __('Product'),
        'public' => true,
        'show_ui' => true, // UI in admin panel
        '_builtin' => false, // It's a custom post type, not built in!
        '_edit_link' => 'post.php?post=%d',
        'capability_type' => 'post',
        'hierarchical' => false,
        'rewrite' => array("slug" => "products"), // Permalinks format
        'supports' => array('title','author')
    ));
}

3 s
3

Have you refreshed your rewrite rules? You can do this by resaving your permalink settings under Settings>Permalinks in the admin.

If it is a plugin or theme you are distributing you can call $wp_rewrite->flush_rules(); upon activation.

Leave a Reply

Your email address will not be published. Required fields are marked *