Where should custom post types be registered in a plugin?

However… I still don’t see the proper place to add this code, in order to follow the plugin standards.

There is no proper place, and there’s no canonical correct answer here, only subjective opinions. The plugin standards do no give an answer for your question.

This boilerplate is just one starting point of many available, and there are lots and lots of options for what you should do, with tradeoffs of their own, or just personal preferences.

The boilerplates folder structure implies a file in the includes folder would do the trick, but you could put it in a subfolder, or an existing file, or a new file, it could be a function, a class, or you could have a separate folder alongside includes called php that has it in there, there’s no right or wrong answer.

Plugin standards say this about the structure of a plugin:

  • It must be a PHP file with a comment at the top containing Plugin Name:
  • That comment can contain other items as well, but it must contain the plugins name, and it must be within the first XX bytes of the file
  • That file can be in the plugins folder, or, in a subfolder
  • That file will be loaded if activated before the theme/query, but after WordPress itself

And that’s it. Your plugin can be structured in any way you want. It can be a function and hook in a standalone file, or it could be a Symfony application with a custom entry point and hundreds of classes and folders. Neither is more correct than the other.

error code: 523