Hi everybody and thanks in advance for helping.

I am experiencing a problem with the categories I have created for my custom post type: when I click on the URL of the category (every category) I get the query error message. It is not a 404 page, it just seems that Wordpress cannot retrieve posts from the taxonomy.

This is code I have used into my functions.php to enable post type and taxonomy:

function themes_taxonomy() {
            'hierarchical'      => true,
            'label'             => 'Categories',
            'show_ui' => true,
            'show_admin_column' => true,
            'query_var'         => true,
            'rewrite'           => array(
                'slug'          => 'category-video',
                'with_front'    => true
add_action( 'init', 'themes_taxonomy');

function custom_post_type() {
    $labels = array(
        'name'                => _x( 'Video', 'Post Type General Name', 'text_domain' ),
    $rewrite = array(
        'slug'                => 'video',
        'with_front'          => true,
        'pages'               => true,
        'feeds'               => true,
    $args = array(
        'label'               => __( 'video', 'text_domain' ),
        'description'         => __( 'Videos', 'text_domain' ),
        'labels'              => $labels,
        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'post-formats', 'custom-fields' ),
        'hierarchical'        => false,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 5,
        'can_export'          => false,
        'has_archive'         => true,
        'exclude_from_search' => true,
        'publicly_queryable'  => true,
        'rewrite'             => $rewrite,
        'capability_type'     => 'post',
        'taxonomies' => array('video_categories'), 
    register_post_type( 'video', $args );
add_action( 'init', 'custom_post_type', 0 ); 

I have already tried flushing cache for urls by updating permalinks but nothing. The archive page works fine for Post Categories therefore it can't be an error on that.

Any ideas?



Your code is fine, I just tested it.

Consider the following: Sometimes you may have a blog and you want URLS to beset up like .xyz/DATE/POSTNAME or perhaps you have a picture website and want it to be .xyz/category/image.

Luckily, Wordpress has built-in functionality to handle this. They are known as Permalinks - you just need set yours up in the desired manner.

To do this, go to the WP admin menu -> settings -> permalinks

Then at the bottom, select 'custom structure' and enter /%category%/%postname%/ in the box. When you assign multiple categories to a post, only one can show up in the permalink.

To get around this, we can use the % symbols tells WordPress that this part of the URL is interchangeable.

Then hit save and try to load a post.

For more information on Permalinks, see here.

  • Awesome. I was trying something similar and ur solution worked. Can you please explain why the happens? – Sid Oct 10 '17 at 11:27
  • @SiddharthVitthaldas I've tried to add more explanation. – Ashtmdu Oct 10 '17 at 11:34

I get the query error message.

What exactly is the error?

Are you using a pre_get_posts filter? Something like:

function video_query_post_type($query) {
  if(is_category() || is_tag()) {
    $post_type = get_query_var('post_type');
        $post_type = $post_type;
        $post_type = array('post','video');
    return $query;
add_filter('pre_get_posts', 'video_query_post_type');
  • Hi and thank you for yor answer. The error I am getting is the classic "Posts not found." which is enabled if the query does not find any post. I am not using pre_get_posts: should I? At the moment, my the custom post type taxonomy is called through archive.php. – gentletechie Nov 22 '14 at 22:28
  • try the pre_get_posts filter – shanebp Nov 22 '14 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.