WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the plugin custom post type ui to create a post type says movie. Everything is ok. I create a movie and its viewable at


however, when i go on


I was expecting to see test as a movie in all the list of movies but nothing is displayed

Code generated by the plugin:

register_post_type('movies', array(
    'label' => 'Movies',
    'description' => '',
    'public' => true,
    'show_ui' => true,
    'show_in_menu' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'rewrite' => array('slug' => ''),
    'query_var' => true,
    'supports' => array(
    'taxonomies' => array('category','post_tag',),
    'labels' => array (
          'name' => 'Movies',
          'singular_name' => 'Movie',
          'menu_name' => 'Movies',
          'add_new' => 'Add Movie',
          'add_new_item' => 'Add New Movie',
          'edit' => 'Edit',
          'edit_item' => 'Edit Movie',
          'new_item' => 'New Movie',
          'view' => 'View Movie',
          'view_item' => 'View Movie',
          'search_items' => 'Search Movies',
          'not_found' => 'No Movies Found',
          'not_found_in_trash' => 'No Movies Found in Trash',
          'parent' => 'Parent Movie',
),) );
share|improve this question
Can you edit your question to show the post type registration code? – Tom J Nowell Apr 20 '12 at 10:10
ok, the code posted is the code generated by the plugin – Noor Apr 20 '12 at 11:01
'slug' => '' - why? – toscho Apr 20 '12 at 13:31
up vote 1 down vote accepted

Simply add has_archive => 'movies' to the arguments array you pass to register_post_type and you should be fine, since by default it is set to false.

share|improve this answer
yes, this solution works. thanks. But still one problem, when I create a post from the new postype, and attach with it a category, when i go on the URL ..../category/<categoryname> – Noor Apr 21 '12 at 9:44
By default category archive only pulls regular posts and not custom ones, but thhe is a another question. – Bainternet Apr 21 '12 at 9:57
then I'll think I must create custom taxonomy then pulls these custom posts – Noor Apr 21 '12 at 10:56
Or simply edit your category archive to show your custom post type – Bainternet Apr 21 '12 at 11:44
I suppose i have to override this in category.php get_template_part( 'loop', 'category' ); – Noor Apr 21 '12 at 12:09

Go to the admin panel and under settings tab go to the permalinks tab and once you are in the permalinks page save changes and try again. This is a hidden trick with wordpress. The cache gets cleared once you visit the permalinks page and save changes. I think this should work for you.

share|improve this answer
All you really have to do is just visit the page -- saving isn't even necessary. – developdaly Apr 20 '12 at 13:25
Unfortunately, same problem, I've noticed that even when attaching a post of custom type with a category, say IT, even when go to .../category/it, it does not show up – Noor Apr 20 '12 at 13:59

I see a number of issues with your code:

'rewrite' => array('slug' => ''),

you can't have a slug of '' it doesn't work. There is no hack around in core to fix this, and there are good reasons regarding permalink clashes for this. I can only assume you're trying to make the custom post work like pages but it won't work this way. Change it to something else or simply make rewrite equal to true

'label' => 'Movies',

You've already defined the labels array, this is unnecessary.

Lastly, the category archive is by default only showing posts of type post. So your movies will not appear there.

To fix this, place this in your functions.php:

add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
  if(is_category() || is_tag()) {
    $post_type = get_query_var('post_type');
        $post_type = $post_type;
        $post_type = array('post','movies'); // replace cpt to your custom post type
    return $query;

In future, indent your code correctly ( I had to fix it in your post, it was unreadable, and unreadable code is usually broken code too ), and use a generator like this one for registering post types and taxonomies

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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