Create a new custom post type ?

before you create a custom post type, you have to reset the permalink to default then create a custom post type like the following


/**
 * Register a custom post type
 *
 * Supplied is a "reasonable" list of defaults
 * @see register_post_type for full list of options for register_post_type
 * @see add_post_type_support for full descriptions of 'supports' options
 * @see get_post_type_capabilities for full list of available fine grained capabilities that are supported
 */
 register_post_type( 'book', array(
 'public' => true,
 'publicly_queryable' => true,
 'show_ui' => true,
 'show_in_menu' => true,
 'query_var' => true,
 'rewrite' => array( 'slug' => 'book' ),
 'has_archive' => true,
 'hierarchical' => false,
 'menu_position' => null,
 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'revisions', 'trackbacks', 'page-attributes', 'custom-fields' ),
 'taxonomies' => array('post_tag', 'category')
 'capability_type' => 'post',
 'capabilities' => array(),
 'labels' => array(
 'name' => __( 'plural_name', 'textdomain' ),
 'singular_name' => __( 'singular_name', 'textdomain' ),
 'add_new' => __( 'Add New', 'textdomain' ),
 'add_new_item' => __( 'Add New singular_name', 'textdomain' ),
 'edit_item' => __( 'Edit singular_name', 'textdomain' ),
 'new_item' => __( 'New singular_name', 'textdomain' ),
 'all_items' => __( 'All plural_name', 'textdomain' ),
 'view_item' => __( 'View singular_name', 'textdomain' ),
 'search_items' => __( 'Search plural_name', 'textdomain' ),
 'not_found' => __( 'No lower_case_plural found', 'textdomain' ),
 'not_found_in_trash' => __( 'No lower_case_plural found in Trash', 'textdomain' ),
 'parent_item_colon' => '',
 'menu_name' => 'plural_name'
 )
 ) );
}
add_action( 'init', 'registration_func_name' );
}

add_action('init', 'my_post_type_news');

then after that alter the permalink as you like
Note: don’t make the permalink to false

Advertisements
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: