Creating a custom post type in a Wordpress Plugin

What we are starting with
includes\class-plugin-name-plugin.php
define_public_hooks(){
// Custom Post Types$this->loader->add_action( 'init', $plugin_public, 'register_cpts' );
public\class-demand-plugin-name-public.php
public function register_cpts() {
// Post Type: Podcasts$labels = ["name" => "Podcasts","singular_name" => "Podcast","add_new_item" => "Add New Episode","edit_item" => "Edit Podcast Episode","new_item" => "New Episode","view_item" => "View Podcast Episode","view_items" => "View Podcast Episodes","search_items" => "Search Podcast Episode",];$args = ["label" => "Podcasts","labels" => $labels,"description" => "","public" => true,"publicly_queryable" => true,"show_ui" => true,"show_in_rest" => true,"rest_base" => "","rest_controller_class" => "WP_REST_Posts_Controller","has_archive" => true,"show_in_menu" => true,"show_in_nav_menus" => true,"delete_with_user" => false,"exclude_from_search" => false,"capability_type" => "post","map_meta_cap" => true,"hierarchical" => false,"rewrite" => [ "slug" => "podcast", "with_front" => true ],"query_var" => true,"menu_icon" => "dashicons-microphone","supports" => [ "title", "editor", "revisions" ],"taxonomies" => [ "category", "post_tag" ],];register_post_type( "podcast", $args );

--

--

--

A junior web developer from the UK learning to be a better developer.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Unstuck: finding flow in software engineering

LeetCode 543- Diameter of Binary Tree

GCP Associate Cloud Engineer Exam Preparation App for iOS, android, Windows10

Build Your Intranet In A Week, Step by Step Guide for Managers

How To Setup/Install VestaCP For Digital Ocean, Vultr And Any Cloud Hosting

Droplet Image selection

QUEUE:

Web scraping |Easy Steps for Web Scraping | Methods | Python

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Matt Calvert

Matt Calvert

A junior web developer from the UK learning to be a better developer.

More from Medium

20 Tips to make your WordPress site more Secure

Sharp for Laravel has a new online demo project

How Laravel Should be The Preferred Choice for Web Development in 2022?

how does broadcast work in Laravel? * DevRohit Think simplified