Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a category on my website called 'profiles' I am in the process of moving this category to a custom post type called 'profiles'.

My problem is I cannot get the archive page to show for this custom post type. When I go to the url mywebsite.com/profiles it takes me to a single post page for a post in the profiles category.

I have included has_archive = true; in my functions.php

I didn't have a problem creating an archive page for another custom post type I did on the same website so Im really lost as to why this is not working this time.

Any advice would be most appreciated?

add_action( 'init', 'profile_custom_init' );

/* Here's how to create your customized labels */
function profile_custom_init() {
$labels = array(
    'name' => _x( 'Profiles', 'post type general name' ), // Tip: _x('') is used for localization
    'singular_name' => _x( 'Profile', 'post type singular name' ),
    'add_new' => _x( 'Add New', 'Profile' ),
    'add_new_item' => __( 'Add Profile' ),
    'edit_item' => __( 'Edit Profile' ),
    'new_item' => __( 'New Profile' ),
    'view_item' => __( 'View Profile' ),
    'search_items' => __( 'Search Profile' ),
    'not_found' =>  __( 'No Profile found' ),
    'not_found_in_trash' => __( 'No Profile found in Trash' ),
    'parent_item_colon' => ''
);

// Create an array for the $args
$args = array( 'labels' => $labels, /* NOTICE: the $labels variable is used here... */
    'public' => true,
    'publicly_queryable' => true,
    'has_archive' => true,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'menu_position' => 10,
    'supports' => array( 'title', 'editor','thumbnail', 'excerpt', 'custom-fields' ),
        'taxonomies' => array('category')
    ); 

    register_post_type( 'profile', $args ); /* Register it and move on */
}
share|improve this question
    
Try changing profile category slug to something else like profiles-2. –  Vinod Dalvi Mar 4 '13 at 10:45
    
Doesnt seem to work. Also if I go to the url mywebsite.com/his for example instead of taking me to a 404 page (I dont have any page or post called just 'His') it takes me to a post beginning with the word 'his'. This seems very strange? –  user1515699 Mar 4 '13 at 10:55
    
Have you tried to save your permalink structure again? This causes the rewrite rules to be regenerated. –  Mike Madern Mar 4 '13 at 11:03
    
Try re saving permalink structure by clicking on Save Changes button of Permalink Settings. –  Vinod Dalvi Mar 4 '13 at 11:04
add comment

2 Answers

  1. Go to Settings->permalinks and change the permalink structure to Default.
  2. After saving the permalink as default revert it to custom structure or post name, it should work and i have tested this.

I hope this can help you.

share|improve this answer
add comment

Re saving the permalink structure seemed to fix the issue. Thanks for the tip Mike and Vinod.

share|improve this answer
add comment

Your Answer

 
discard

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.