Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Wordpress Custom Post Type

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 329
    Comment on it

    We can create our own custom post types.

    We can call them whatever we want.

    They are content types like posts and pages.

    We create a custom post type for adding different feature to our website.

    We can add category to our post.

    For creating a custom post type we have to add function in function.php.

    // Our custom post type function
    
        function create_post_type() {
    
    
            register_post_type( 'movies',
            // CPT Options
    
    array(
    
                    'labels' => array(
    
                        'name' => _( 'Movies' ),
    
                        'singular_name' => _( 'Movie' )
    
                    ),
    
                    'public' => true,
    
                    'has_archive' => true,
    
                    'rewrite' => array('slug' => 'movies'),
    
                )
    
            );
    
        }
    
        // Hooking up our function to theme setup
    
        add_action( 'init', 'create_post_type' );
    

    this code registers a post type 'movies' with an array of arguments.

    These arguments are the options of our custom post type.

    This array has two parts, the first part is labels, which itself is an array.

    The second part contains other arguments like public visibility, has archive, and slug that will be used in URLs for this post type.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: