How can I create a custom post type with empty slug?
-
I’m working with custom post types, I’ve developed a plugin with no problems. the problem is when I try to set a empty slug. The permalink is created correctly but I always get 404 error with this URL.
https://www.domain.com/test/post-name/ this works fine.
https://www.domain.com/post-name/ this get 404 , but this is that I want.I’m wondering if it is possible to obtain this config, without touching the core of WP and make it forward compatible
Thanks!
function create_post_type() { register_post_type( 'test', array( 'labels' => array( 'name' => __( 'test' ), 'singular_name' => __( 'tests' ) ), 'public' => true, 'rewrite' => array( 'slug' => '', 'with_front' => true) ) ); }
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
- The topic ‘How can I create a custom post type with empty slug?’ is closed to new replies.