How to make your own custom plugin from scratch using a pure PHP function and word press built in functions utilizing register_post_type();
//register_post_type( string $post_type, array|string $args = array() )
Steps
1. create a new file to add the registering code for example products-catalog-post.php , gallery-post-.php , and then including that in the functions.php
2. in your new products-catalog-post.php
2.1 register your custom post type with the id and the wp variable $args
2.2 add the appropriate $labels=[ ]; and $args=[ ];
2.3 add the action hook init and the function name
3. Check your plugin with each step added.
check the git commit for the example done in this video
GIT Commit : https://github.com/andgo-edu/bootstra...
Useful links
1. Avoid using these Reserved Post Types
https://developer.wordpress.org/refer...
The following post types are reserved and are already used by WordPress.
post
page
attachment
revision
nav_menu_item
custom_css
customize_changeset
oembed_cache
user_request
wp_block
In addition, the following post types should not be used as they interfere with other WordPress functions.
action
author
order
theme
LINK:https://developer.wordpress.org/refer...
2. get_post_type_labels
Builds an object with all post type labels out of a post type object.
LINK: https://developer.wordpress.org/refer...
3. $args
(array|string) (Optional) Array or string of arguments for registering a post type.
4. label
is a (string) Name of the post type shown in the menu. Usually plural. Default is value of $labels['name'].
LINK: https://developer.wordpress.org/refer...
5 . * 'labels' is a
*(string[]) An array of labels for this post type. If not set, post labels are inherited for non-hierarchical types and page labels for hierarchical ones. See get_post_type_labels() for a full list of supported labels.
6. public (bool)
Whether a post type is intended for use publicly either via the admin interface or by front-end users. While the default settings of $exclude_from_search, $publicly_queryable, $show_ui, and $show_in_nav_menus are inherited from $public, each does not rely on this relationship and controls a very specific intention. Default false.
LINK: //https://developer.wordpress.org/refer...
7. show_ui
(bool) Whether to generate and allow a UI for managing this post type in the admin. Default is value of $public.
LINK:
8.rest_controller_class
(string) REST API controller class name. Default is WP_REST_Posts_Controller'.
LINK: https://developer.wordpress.org/refer...
9. capability_type (string|array) The string to use to build the read, edit, and delete capabilities. May be passed as an array to allow for alternative plurals when using this argument as a base to construct the capabilities, e.g. array('story', 'stories'). Default 'post'.
10. supports
supports is an (array/boolean) (optional) An alias for calling add_post_type_support() directly. As of 3.5, boolean false can be passed as value instead of an array to prevent default (title and editor) behavior.
LINK: https://developer.wordpress.org/refer...