create a plugin to add a video custom post type.

Home » Snippets » create a plugin to add a video custom post type.
0

Created with:

Visibility: 

public

Creator: Vikas InstaWP

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project
					<?php
/*
Plugin Name: Video Custom Post Type
Description: Adds a custom post type for videos.
Version: 1.0
Author: WP Turbo
Author URI: https://wpturbo.dev
Text Domain: wpturbo
*/

// Register the video custom post type
function wpturbo_register_video_post_type() {
    $labels = array(
        'name'          => esc_html__( 'Videos', 'wpturbo' ),
        'singular_name' => esc_html__( 'Video', 'wpturbo' ),
        'add_new'       => esc_html__( 'Add New Video', 'wpturbo' ),
        'edit_item'     => esc_html__( 'Edit Video', 'wpturbo' ),
        'view_item'     => esc_html__( 'View Video', 'wpturbo' ),
        'search_items'  => esc_html__( 'Search Videos', 'wpturbo' ),
        'not_found'     => esc_html__( 'No videos found', 'wpturbo' ),
        'menu_name'     => esc_html__( 'Videos', 'wpturbo' ),
    );

    $args = array(
        'labels'             => $labels,
        'public'             => true,
        'has_archive'        => true,
        'menu_icon'          => 'dashicons-video-alt',
        'supports'           => array( 'title', 'editor', 'thumbnail' ),
        'rewrite'            => array( 'slug' => 'videos' ),
    );

    register_post_type( 'video', $args );
}
add_action( 'init', 'wpturbo_register_video_post_type' );
				

Explanation:

Please make sure to save this code in your 'wp-plugin.php' file and activate the plugin. After activation, you will see a new menu item 'Videos' in your WordPress dashboard, where you can add and manage your video posts.

Let me know if you need any further assistance!

Register an account to save your snippets or go Pro to get more features.