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've created a custom post type called 'product'. I want to add a page link to 'products' in the menu, but I don't have that option.

I would like to know if there is a way of displaying it the same way as if it were like a category... a page that shows all the 'products' like if they were posts, and that I could add to the menu.

At this stage I can only add specific 'products' but not a link to a list of them.

Any suggestions on how to make this work?

share|improve this question

2 Answers 2

up vote 0 down vote accepted

In addition to @Rarsts answer, once you've created a custom post type with archive like this example:

//* Create product custom post type
add_action( 'init', 'register_product_custom_post_type' );
function register_product_custom_post_type() {

register_post_type( 'product',
    array(
        'labels' => array(
            'name'          => __( 'Product', 'wpsites' ),
            'singular_name' => __( 'Product', 'wpsites' ),
        ),
        'has_archive'  => true,
        'hierarchical' => true,
        'menu_icon'    => 'dashicons-portfolio',
        'public'       => true,
        'rewrite'      => array( 'slug' => 'product', 'with_front' => false ),
        'supports'     => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'revisions', 'page-attributes' ),
        'taxonomies'   => array( 'product-type' ),

    ));

}

You can also control that archive using pre_get_posts.

add_action( 'pre_get_posts', 'customize_custom_post_type_archive' );

function customize_custom_post_type_archive( $query ) {
if ( is_post_type_archive('product') && $query->is_main_query() )

    $query->set( 'posts_per_page', '6' );
    $query->set( 'order', 'ASC' );
return $query;
}

You can then add your CPT archive link as a custom URL to your menu

http://example.com/product/

share|improve this answer

What you are looking for is custom post type archive. First you should make sure that your CPT is registered to have archive at all.

Unfortunately natively WP doesn't add CPT archives as available to be included in menus. The simplest solution is just to add custom link to it.

There are also multiple snippets and plugins to address this floating around, from quick look up I have Post Type Archive Link bookmarked.

share|improve this answer

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.