WordPress: Add a Custom Post Type

If you need another post type in addition to posts and pages (for example, for downloads), you can implement this with a simple plugin.

Create a new file in the /wp-content/plugins folder. For example: custom-post-type.php

Add this to your custom-post-type.php file:

/**
 * Plugin Name: Custom Post Type
 * Author:      iAppMag.de
 * Version:     1
 */

function wpblog_create_custom_post_type() {
  // Register your custom post type
  register_post_type( 'CUSTOM POST TYPE',
      array(
          // Set a name for your post type in plural and singular
          'labels' => array(
          	'name' => __( 'CUSTOM POST TYPE' ),
          	'singular_name' => __( 'CUSTOM POST TYPE' )
          ),
          // This post type will be public
          'public' => true,
          // URL: http://example.com/CUSTOM/
          'rewrite' => array('slug' => 'CUSTOM'),
          // this post type supports a title, some content with the normal editor and an author
	  'supports' => array( 'title', 'editor', 'author' )
      )
  );
}

add_action( 'init', 'wpblog_create_custom_post_type' );

Sharing is caring...

Posted by Phil

Ersten Kommentar schreiben

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.


*