Pretty permalinks for custom post type archives
-
Currently my custom post type archives are can be accessed by either
mysite/mycustomposttype
or
mysite/?post_type=mycustomposttype
This is not good in terms of duplicate content on search engines etc.
Permalinks are operative using Permalink settings: /%year%/%postname%/
Individual CPT are fine.
Seems like CPT archives are not getting the proper rewrite treatment. So my question – is something broken or do they require rewrites to be set up manually elsewhere?
add_action( 'init', 'create_my_post_types' ); function create_my_post_types() { register_post_type( 'mycustomposttype', array( 'labels' => array( 'name' => __( 'Mycustomposttype' ), 'singular_name' => __( 'Mycustomposttype' ), 'add_new' => __( 'Add New Mycustomposttype Listing' ), 'add_new_item' => __( 'Add New Mycustomposttype Listing' ), 'edit' => __( 'Edit' ), 'edit_item' => __( 'Edit Mycustomposttype Listing' ), 'new_item' => __( 'New Mycustomposttype Listing' ), 'view' => __( 'View Mycustomposttype' ), 'view_item' => __( 'View Mycustomposttype Listing' ), 'search_items' => __( 'Search Mycustomposttype Listings' ), 'not_found' => __( 'No Mycustomposttype Listing found' ), 'not_found_in_trash' => __( 'No Mycustomposttype Listing found in Trash' ) ), 'description' => __( 'Mycustomposttype' ), 'public' => true, 'show_ui' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'menu_position' => 5, 'hierarchical' => true, 'query_var' => true, 'supports' => array( 'title', 'editor', 'comments', 'trackbacks', 'revisions', 'author', 'excerpt', 'custom-fields', 'page-attributes', 'thumbnail', 'post-formats' ), 'rewrite' => array( 'slug' => 'mycustomposttype', 'with_front' => false ), 'taxonomies' => array( 'post_tag','category','stuff','other-stuff' ), 'has_archive' => true, 'show_in_nav_menus' => true, 'can_export' => true, ) );
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Pretty permalinks for custom post type archives’ is closed to new replies.