WordPress.org

Forums

Default page for custom post type (3 posts)

  1. jepser
    Member
    Posted 4 years ago #

    As you know, category.php is the default list for categories, I mean if I want to check all posts of a category, category.php handles it.

    Also with tag.php, author.php, taxonomy.php them show all the posts depending of the criteria. So what name a have to use if I want to display all post of a custom post type?
    post-type-name.php ? with a loop like category.php?

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    well, to show all posts in a custom post type, you make a page template.

    I made a copy of my index.php, named in shop.php (since mine is for a shop) and put this in fron of the loop:

    query_posts( array(
    	// Set post type
    	'post_type' => 've_products',
    	// Enabled paging
    	'paged'=> ( get_query_var('paged') ? get_query_var('paged') : 1 ),
    ));

    my post type was ve_products

    you can use single-posttype.php to display the single view of your custom post type, if you want it to be styled differently than normal posts. Otherwise it will use your standard single.php

    then make a new page in WP's page editor, and assign it the template you just made with the custom query.

  3. jepser
    Member
    Posted 4 years ago #

    thanks dude, I think I will do that, I mean I didn't want to make that just imagine that your developing a wp theme that is for sale and the user can registar N quantity of post types, and the client insn't an expert in php.

    But thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic