[resolved] Pretty permalinks for custom post type archives (8 posts)

  1. Bob33
    Posted 3 years ago #

    Currently my custom post type archives are can be accessed by either




    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',
            '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,
  2. Alessio Lo Vecchio
    Posted 3 years ago #

    You don't have duplicate content if you link only one URL mysite/mycustomposttype in example. BTW you can use rel="canonical" to specify which url Google has to consider as original.

  3. Bob33
    Posted 3 years ago #

    Hi YouON,

    I'm only using the mysite/mycustomposttype URLs for any links, however for some reason google is crawling mysite/?post_type=mycustomposttype

    My understanding is that if rewrites were working properly mysite/?post_type=mycustomposttype would take you to mysite/mycustomposttype.

    If I navigate to mysite/?p=2, for instance, I'll end up at mysite/about/

  4. Bob33
    Posted 3 years ago #

    Update: tracked down a link in the CPT post footer generated by the theme with the mysite/?post_type=mycustomposttype structure and fixed this.

    And to clarify, the archives will always be reachable via mysite/?post_type=mycustomposttype or mysite/mycustomposttype

    However, I'm still keen to know why mysite/?post_type=mycustomposttype is not redirected to mysite/mycustomposttype

    Any insights appreciated.

  5. Alessio Lo Vecchio
    Posted 3 years ago #

    I see two site of mine, and the same thing happens to me... I don't think is an issue (I'm a SEO consultant)... go further without problems :)

    With the "site:" command on Google do you see the "?post_type=" url indexed?

  6. Bob33
    Posted 3 years ago #

    Ah - good skills YouON! Should have thought of trying that :)

    No, can't see both indexed - I guess Google is clever enough to sort it.

    I noticed Google crawling those pages in a stats program which got me started. But at least the duplicate content issue is resolved.

    Thanks for the tip!

  7. Alessio Lo Vecchio
    Posted 3 years ago #

    BTW thinking about use rel=canonical to avoid any duplicate content issue :)

  8. Bob33
    Posted 3 years ago #

    OK, thanks YouON

Topic Closed

This topic has been closed to new replies.

About this Topic