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 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?

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

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

share|improve this answer
add comment

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
) );
share|improve this answer
    
technically you can paginate a page containing posts, it's just a bit manual. –  Milo Jun 15 '11 at 15:53
    
Of course, but at that stage you'd need a very specific reason not to use the has_archive arg. –  TheDeadMedic Jun 15 '11 at 16:08
add comment

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.