Is it proper to create a page just to generate a listing page (eg. for a custom post type)

I find myself creating pages just as a “placeholder” to a listing page.

eg. I create a page “Blog” and “Portfolio”. Both has the editor emtpy. And I just use it so that I can use page-blog.php and page-portfolio.php for the respective listing pages. It doesnt seem proper? Is there a better way?

Related posts

Leave a Reply

2 comments

  1. I guess another way would be including 'has_archive' => true, into your register_post_type array and using archive-{posttype}.php to style your custom post type listings

  2. I only use ‘placeholder’ pages if I’m listing just a few custom post types with no pagination (or any other miscellaneous data for that fact), so that the end user still has control over the things like the title & content (which you can use for introductory text and so forth).

    It also has the advantage of getting listed in wp_list_pages(), which is handy if you’re using it for navigation elsewhere in your theme.

    However, as @Daniel said, if you want to make benefit of a full-blown archive with pagination & feeds, opt for the has_archive arg.

    I tend to use a different slug for the archive as opposed to the single post, just for clarity.

    So for example;

    http://example.com/product/my-single-product/

    And for archives;

    http://example.com/products/

    http://example.com/products/page/2

    http://example.com/products/feed/

    The code for it?

    register_post_type( array(
        'rewrite' => array(
            'slug' => 'product', // defaults to post type name
            'with_front' => true, // prepends slug to single posts, default true
            'pages' => true, // support pagination, default true
            'feeds' => true // support feeds, default matches 'has_archive'
         ),
    
         'has_archive' => 'products' // if bool true, defaults to rewrite slug
    ) );