Support » Developing with WordPress » Reuse custom post types in a new theme?

  • Hello,
    I’m relatively new to custom post types in WordPress. I am working on creating a new theme for a site that needs to be upgraded to 4.7.2, but doing so causes the custom theme to not work. This site had a custom post type called “articles” created that works just like “posts” but with additional options and fields and it’s where all of the content has been created for the different news/blog feeds. I’m hoping I can reuse this custom post type in the new theme I’m creating?

    I’m working locally on a site copy while the live site is untouched, I’ve made all the updates to the WP core and the plugins. I was planning to use the gantry5/hydrogen theme to create the new site (I know this isn’t the gantry5 gitter, just adding the detail), what do I need to do to incorporate these custom post types into a new theme? My thoughts are that I’ll need to create a layout file, in this case calling it “article.php”, in the new dev theme.

    Can I also take the old php code calling this custom post type from the old theme and use that within my new theme’s page layout for article.php? So basically I’d leave all the custom post type the way it is and just pull it into my new theme in the correct layout?

    • This topic was modified 3 years, 8 months ago by traveler. Reason: cut out some extra text
Viewing 3 replies - 1 through 3 (of 3 total)
  • You can register the post type with your current theme by using register_post_type()

    There are several plugins also which can help you in creating custom post types.

    One of them is the Custom Post Type UI plugin

    • This reply was modified 3 years, 8 months ago by Patrick.

    Hey Patrick,
    Thanks for your response, I feel like it’s such a basic question but I’m trying to plan a build time and this has been giving me some issues (in my planning process..). So the site is currently using that custom post type ui plugin you linked to above, and all the custom post types needed were created and live with the current old site that’s being replaced. I’m just building a new theme for the site and don’t wish to change anything in the admin section.

    Since the site is using that plugin, and I do have the top-level admin screen to manage/create/edit “articles” in the site, does this mean that this custom post type is already registered with my theme?

    The way the old site was set up, there were 7 blog feeds on the site, the homepage and then a feed for region pages 1-7. The site has no posts at all. Each blog feed is made up of the articles which have many more options associated with them than a typical post. For each article, when creating or editing there are checkbox options for feature on homepage, hide from blog feed, hide next/previous post bar, and a region selector dropdown to select which region blog feed to assign it to. There are other options for social media, but the above are the ones which are always assigned to determine where an article goes.

    So my confusion is coming from how do I get these different custom article feeds to display on my theme. I’ve only displayed pages and posts in the past so I didn’t have to deal with a custom field like this.

    Moderator bcworkz


    Showing up in admin is a result of the plugin, it doesn’t mean your theme knows how to deal with the extra data. You theme can deal with the basic title, content, etc. in some basic, generic way. To deal with any special formatting and data, you should find the template(s) used by the original theme that do deal with this and somehow merge/adapt them to your theme.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Reuse custom post types in a new theme?’ is closed to new replies.