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

So I created a custom post type like

add_action('init', 'create_post_type');

function create_post_type() {
      'labels' => array(
        'name' => 'Portfolio',
        'add_new_item' => 'Add New Portfolio Item',
        'edit_item' => 'Edit Portfolio Item'
      'public' => true,
      'capability_type' => 'post',
      'supports' => array('title', 'editor', 'thumbnail', 'excerpt'),
      'menu_position' => 5

When I add a new custom post (http://localhost/wordpress/portfolio/portfolio-item-3/) and try going to that page, I get a 404. Whats wrong?


This solution works but what does it do and it sounds like its not good to keep flushing my rewrite rules isit?



after you call register_post_type.

share|improve this question
up vote 2 down vote accepted

All that does is reset the rewrite rules. You could do the same by visiting the permalinks page and clicking save. You do need to reset them once but not every time. There is no need to flush every time you call register_post_type

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.