I've searched for good guides for hours now, but with no luck. I want to create a custom Page Type with custom fields. There are 100s of guides on how to create that using some of the popular plugins and it seems to work just fine.

The thing is, I might occasionally need to create a much more advanced custom page type and I've found no guide that helps me extend a custom page type with my own PHP code.

My lack of luck finding guides on how to manually extend page types might be because it's a lot better to create a plugin for it, it might be because I'm horrible at using Google or it might be because people just don't do that manually since everything can be achieved easily with plugins if you're familiar enough with them.

I'm well aware that the answer might be "It depends on what you want to do", so I'll just make up a scenario:

I need to create a custom page type with the usual basic stuff: Headline, Content WYSIWYG, Categories, Thumbnail and Excerpt, this CPT will also need another area, let's say that it needs an area to create timetables for school classes, those timetables needs to be sortable by drag and drop and other slick JS stuff.

In this scenario - would I create a plugin that manually includes the ordinary page stuff and adds the extra functionality? Or would I create a CPT and somehow manually extend it with the extra functionality I need.

Sorry if I could have made it shorter, I'm very new to WP and struggleing to get a hold of all the correct jargon :)

Best John

1 Answer 1


First of all, keep it in your mind that WordPress convention says theme is only for presentation and plugin is for functionality. So that means if you need to initiate any functionality you should do that in plugin and when you represent the data visually in frontend you need to do it with theme.

Now at your case you can initiate the custom post type in plugin and represent the CPT data with necessary templates(Like single.php, archive.php etc.) through theme. This way you can separate the view and business logic part.

For initiating the CPT you can use a pre-built class like the below one- https://github.com/jjgrainger/wp-custom-post-type-class

I use this one for initiating CPT for any of my projects. You can also use it with composer.json. This class will also take care of custom taxonomy and other post type support like visual editor, default fields and so on. Read the README.md file of this class and you'll get a full overview on how to use it with WordPress.

Hope it helps.

  • Hi, Thanks for the reply. I'm currently looking at the class. I just got the difinition on what the "Page Type" should be able to do: It needs to contain everything an ordinary page does, but after that the user needs to be able to add "content area blocks" with the ability to choose between three different types of content: BlockType #1: A content area with a headline, a text and a gallery BlockType #2: A content area with a textarea and 4 images BlockType #3: Something else The user needs to be able to add as many block as he/she wants to. Does this sound like a plugin? :)
    – John
    May 15, 2017 at 6:04
  • Yep. Everything related to functionality should go inside plugin. And for showing the data you have to use theme template. Clear ? And another thing, if this answer helps you then please accept it. There is a check mark left side of the answer. Please check it for accepting the answer.
    – CodeMascot
    May 15, 2017 at 6:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.