Post types

This documentation for the Custom post types plugin for WordPress allows you to customize all features.

To get professional support you need to make a donation to get the PRO version of the plugin.

You can add as many post types as you like, as for the native WordPress public post types (posts and pages), if they are registered as public they will be present in the administrative menus and will be reachable from the frontend (single post type page).

New post type using UI

Registering and adding a new post type to your WordPress website has never been easier directly from the administration area.

  1. From the “Extend / Manage” menu click on the “Post types” item;
  2. From the “Post types” page at the top click on the “Add post type” button;
  3. Configure the new post type and click on the “Publish” button;
  4. The item relating to the post type created “Products” will be added to the main menu;
  5. Create and publish a “Product” as a blog post;
  6. See the new “Product” in the frontend;

cpt_post_types_register

apply_filters( 'cpt_post_types_register', $registered_post_types )

Filter the registered post types data.

Parameters
  • $registered_post_typesarray

    Array of registered post types.

Example:

add_filter('cpt_post_types_register', function($post_types){
    $post_types[] = [
        'id' => 'products',
        'singular' => 'Product',
        'plural' => 'Products',
        'args' => [], // Array or string of arguments for registering a post type.
        'labels' => [] // An array of labels for this post type.
    ];
    // See https://developer.wordpress.org/reference/functions/register_post_type/
    return $post_types;
});
This code is an example, add it to theme’s functions.php file or to custom plugin.

cpt_post_types_register_labels

apply_filters( 'cpt_post_types_register_labels', $registration_labels, $id )

Filter the registered post types labels.

Parameters
  • $registration_labelsarray

    Array of post type labels.

  • $idstring

    Post type registration id.

Example:

add_filter('cpt_post_types_register_labels', function($registration_labels, $id){
    if('products' == $id){
        $registration_labels['edit_item'] = 'Customize product';
        // See https://developer.wordpress.org/reference/functions/get_post_type_labels/
    }
    return $registration_labels;
}, 10, 2);
This code is an example, add it to theme’s functions.php file or to custom plugin.

cpt_post_types_register_args

apply_filters( 'cpt_post_types_register_args', $registration_args, $id )

Filter the registered post types args.

Parameters
  • $registration_argsarray

    Array of post type args.

  • $idstring

    Post type registration id.

Example:

add_filter('cpt_post_types_register_args', function($registration_args, $id){
    if('products' == $id){
        $registration_args['hierarchical'] = true;
        // See https://developer.wordpress.org/reference/functions/register_post_type/
    }
    return $registration_args;
});
This code is an example, add it to theme’s functions.php file or to custom plugin.
*** *******