Custom post type - disabling query_var gets 404?
I don't want my custom post type to be loaded by using query string at ?{query_var}={post_slug}
. So I have set the argument below in my custom post type:
'query_var' = false,
But this gives me a 404 page when I load my custom post type page using clean URL, for examples:
/news/news-sample-1/
/news/news-sample-2/
/news/news-sample-3/
Why? What have I set wrong? Below is my custom post type declaration:
function news_init() {
$args = array(
'labels' = array(
'name' = __('News (Pages)'),
'singular_name' = __('News'),
'all_items' = 'All News'
),
'public' = true,
'show_ui' = true,
'capability_type' = 'page',
'hierarchical' = true,
'rewrite' = array(
'slug' = 'news',
'with_front' = true
),
'query_var' = false,
'menu_icon' = 'dashicons-star-filled',
);
register_post_type('news', $args);
}
add_action('init', 'news_init');
Any ideas?
Or is it a WP bug? I do exactly what it says on the doc.
Topic query-variable wp-query custom-post-types Wordpress
Category Web