Build Status Stable Release License

Extended CPTs

Extended CPTs is a library which provides extended functionality to WordPress custom post types, allowing developers to quickly build post types without having to write the same code again and again.

See also: Extended Taxonomies.

Improved defaults

Extended admin features

Extended front-end features

Usage

Need a simple post type with no frills? You can register a post type with a single parameter:

register_extended_post_type( 'article' );

Try it. You'll have a hierarchical public post type with an admin UI, and all the labels and post updated messages will be automatically generated. Or for a bit more functionality:

register_extended_post_type( 'story', array(

    # Add the post type to the site's main RSS feed:
    'show_in_feed' => true,

    # Show all posts on the post type archive:
    'archive' => array(
        'nopaging' => true
    ),

    # Add some custom columns to the admin screen:
    'admin_cols' => array(
        'featured_image' => array(
            'title'          => 'Illustration',
            'featured_image' => 'thumbnail'
        ),
        'published' => array(
            'title'       => 'Published',
            'meta_key'    => 'published_date',
            'date_format' => 'd/m/Y'
        ),
        'genre' => array(
            'taxonomy' => 'genre'
        )
    ),

    # Add a dropdown filter to the admin screen:
    'admin_filters' => array(
        'genre' => array(
            'taxonomy' => 'genre'
        )
    )

), array(

    # Override the base names used for labels:
    'singular' => 'Story',
    'plural'   => 'Stories',
    'slug'     => 'stories'

) );

Bam, we have a 'Stories' post type, with correctly generated labels and post updated messages, three custom columns in the admin area (two of which are sortable), stories added to the main RSS feed, and all stories displayed on the post type archive.

There's quite a bit more you can do. See the wiki for more examples.

Contributing and Testing

Please see CONTRIBUTING.md for information on contributing.

Please see the tests readme for information on running the unit test suite.

License: GPLv2 or later

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.