• Resolved Bob33

    (@bob33)


    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)
  • 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.

    Thread Starter Bob33

    (@bob33)

    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/

    Thread Starter Bob33

    (@bob33)

    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.

    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?

    Thread Starter Bob33

    (@bob33)

    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!

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

    Thread Starter Bob33

    (@bob33)

    OK, thanks YouON

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Pretty permalinks for custom post type archives’ is closed to new replies.