Support » Plugins » Hacks » Custom Post Type inside another Custom Post Type

  • Hello,

    I’m looking into creating a custom plugin and was wondering if it is possible to have a post type inside another post type… An example of how this would work would be a slideshow:

    You click on the slideshow CPT from the left-side menu in WordPress admin and it shows a list of slideshows you have. When you click on a slideshow it opens a new list of slides inside the slideshow… Meteor slides does this same thing. Basically, a CPT inside a CPT…

    Anyone know how this is done?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Travis

    (@tjtaylor)

    Nevermind, Meteor slides uses a Taxonomy to do this. I still wonder if this is possible, and I feel like I’ve seen other plugins do this…

    I don’t think WordPress offers any built-in abliity to relate post types in this way. You can still use a separate post type (or taxonomy) as a means to handle data, then include items within your primary post type.

    One way to think of this is default Galleries created with the “Add Media” button. Each image is an “attachment” post type, which can be added to your post. Galleries insert a list of IDs that reference each image.

    You’ll want to use wp_insert_post to create new items, to get you started. You should only use post types if you actually want to utilize post types for their default behavior, such as editing them individually, viewing them on the front end, and adding them to menus.

    If you just want to store a list of title/text/image, it’s better to use an array. Custom post meta supports arrays.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Post Type inside another Custom Post Type’ is closed to new replies.