Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WordPress: Page-Template functionality for Custom Post Types

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #32545
    shbaxt
    Member

    I need to have the page-template functionality for a custom post type, ‘products.’

    I have a list of product pages divided into 4 groups—each group has its own template. I would like to move these pages into a custom post type to make it easier on admins to add/remove/edit products without sifting through the other items under “Pages.”

    I have the custom post type created and behaving like a page (hierarchical and supports => ‘page-attributes’), but I need the page-template functionality.

    Is there any way I can implement page-template functionality or do I need to find a different solution?

    I found this discussion, but it comes short of answering my question.

    #48747
    mixxmac
    Member

    You can add a template file to be used for a custom post type…

    … “In the same way that posts are shown on their own page with single.php, custom post types will use single-{posttype}.php if it’s available.”

    See: http://codex.wordpress.org/Post_Types

    #48738
    shbaxt
    Member

    Thanks for the link mixxmac.

    To use this solution, I would need to make 4 separate custom post types (for the 4 categories of products). That might be the route I need to take, but I was hoping for a simpler solution first.

    #48741
    mixxmac
    Member

    Maybe you could try using a custom field within your post e.g. product-type, and then some conditional logic to generate the markup based on this field.

    There’s a great screencast on this type of thing here:
    https://css-tricks.com/video-screencasts/65-advanced-uses-for-custom-fields-in-wordpress/

    The video seems to cover the same type of thing you described.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Back End’ is closed to new topics and replies.