PHPackages                             pelmered/post-types-creator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. pelmered/post-types-creator

AbandonedArchivedWordpress-plugin[Utility &amp; Helpers](/categories/utility)

pelmered/post-types-creator
===========================

Helper plugin for easily creating localize-ready custom post types and custom taxonomies in WordPress

1.0.2(9y ago)1217.1k↓100%2GPL-2.0+PHP

Since Jan 17Pushed 9y ago1 watchersCompare

[ Source](https://github.com/pelmered/post-types-creator)[ Packagist](https://packagist.org/packages/pelmered/post-types-creator)[ Docs](https://github.com/pelmered/Post-types-creator)[ RSS](/packages/pelmered-post-types-creator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (8)Used By (0)

Post types creator
==================

[](#post-types-creator)

[![Build Status](https://camo.githubusercontent.com/5c12bc6c6c276fb4e63edc151fd1a3e9d08f29d779519b4b0354c0793ed0f115/68747470733a2f2f7472617669732d63692e6f72672f70656c6d657265642f706f73742d74797065732d63726561746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/pelmered/post-types-creator)

Helper plugin that provides an easy interface for creating fully translated custom post types and taxonomies according to best practice with only a few lines of code for WordPress.

**Contents**

- [Features](#features)
- [Planned features](#planned-features)
- [Common problems &amp; troubleshooting](#common-problems-&-troubleshooting)
- [Installation](#installation)
    - [Composer](#composer)
    - [Normal manual install](#normal-manual-install)
    - [Use the example plugin as a boilderplate for your custom post type plugin](#use-the-example-plugin-as-a-boilderplate-for-your-custom-post-type-plugin)
- [Usage](#usage)
    - [Adding custom post types](#adding-custom-post-types)
        - [Minimal:](#minimal)
        - [Example / typical:](#example--typical)
    - [Adding taxonomies:](#adding-taxonomies)
    - [More examples / Example plugin](#more-examples--example-plugin)

\##Features

- Easy interface, just a few lines of code requiered.
- Flexible. Does not restrict anything, you can pass any arguments to `register_post_type()` and `register_taxonomy()` by simply specifying them in the normal way and they will override the defaults.
- Translation ready (All the labels in WP Admin will be translated and you only need to specify singular and plural form of the post type name). Translation currently supports the following languages:
    - English
    - Swedish
    - Norwegian
    - Plase help me to add more!
- Translated permalinks/slugs for post types and taxonomies are generated automatically, but it is possible to override this deafault.
- Custom columns in admin with only a few lines of code
- easily add custom post statuses
- Drag &amp; drop sortable (drag and drop in the normal list view in WP Admin for both posts and taxonomies/terms)
- Integration with Advanced Custom Fields(optional)

\##Planned features for version 2.0

- Complete rewrite of better code structure and quaility
- More unit tests (Initial goal is at least 50% code coverage)
- Scaffolding command for WP-CLI to genereate plugin
- Use new term meta functionality for sorting for WordPress 4.4+

\##Common problems &amp; troubleshooting

The plugin is very simple to use if you know basic PHP. Most of the problems you are likely to run into is related to WordPress built in permalink cache or messed up or non-existing meta data for sorting(the posts will not show up in the post linst in wp-admin). To fix both those problems. Just add `&ptc-reinit=1` to the URL/querystring anywhere in wp-admin to run a force reinitialization that will fix the problems, for example: `http://example.com/wp-admin/edit.php?post_type=page&ptc-reinit=1`

\##Installation

\###Composer Add the repository and add `pelmered/post-types-creator` to the require section in your composer.json. Example of typical full composer.json file:

```
{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/pelmered/post-types-creator"
    }
  ],
  "require": {
    "pelmered/post-types-creator": "dev-master"
  },
  "extra": {
    "wordpress-install-dir": "public/wp",
    "installer-paths": {
        "public/wp-content/plugins/{$name}/": ["type:wordpress-plugin"]
    }
  }
}

```

Note: Edit the installer paths to reflect your installation

\###Normal manual install First, install the plugin as usnual by uploading the plugin to you plugins folder, typically `wp-content/plugins/ `.

\###Use the example plugin as a boilderplate for your custom post type plugin Secondly, copy the example plugin from `example-plugin/my-custom-post-types/` in this plugin to your plugins folder, typically `wp-content/plugins/` or install the example plugin from the zip file in `example-plugin/my-custom-post-types.zip`. Change the name, description etc of the plugin and edit the data acording to your needs.

\##Usage

\###Adding custom post types

\####Minimal: Registers a post type with the slug `stores` and the labels tranlatable based on `Post type plural` (plural) and `Post type singular` (singular).

```
$options = array(
  // Use ACF for storing meta data
  'use_acf' => true
);

$ptc = new \PE\Post_Types_Creator();
$text_domain = 'text-domain';

$ptc->set_post_types(array(
    'stores' => array(
        'singular_label' => _x('store', 'Post type singular', $text_domain),
        'plural_label'  => _x('stores', 'Post type plural', $text_domain)
    )
));

add_action( 'init', array($ptc, 'init'), 0 );
```

\#####Example / typical: Same as minimal, but allso adds a description, makes it drag and drop sortable in the admin list, adds a custom admin column and overides some `register_post_type()` defaults, for example connecting the taxonomy `area`(see example below).

```
$ptc = new \PE\Post_Types_Creator();
$text_domain = 'text-domain';

$ptc->set_post_types(array(
    'stores' => array(
        'singular_label' => _x('store', 'Post type singular', $text_domain),
        'plural_label'  => _x('stores', 'Post type plural', $text_domain),
        'description'   => _x('All company stores', 'Post type description', $text_domain),

        // Make post type drag and drop sortable in admin list view (default: false)
        'sortable'      => true,
        'taxonomy_filters' => true,
        'admin_columns' => array(
            'image' => array(
                //Column header/label
                'label' => 'Image',
                //In what position should the column be (optional)
                'location'  => 2,
                //callback for column content. Arguments: $post_id
                'cb'    => 'example_get_featured_image_column'
            )
        )

        // Override any defaults from register_post_type()
        // http://codex.wordpress.org/Function_Reference/register_post_type
        'supports'            => array( 'title', 'editor', 'thumbnail',),
        'taxonomies'          => array( 'area' ),
    )
));

add_action( 'init', array($ptc, 'init'), 0 );

function example_get_featured_image_column( $post_id )
{
    echo get_the_post_thumbnail( $post_id, 'thumbnail' );
}
```

\####Adding taxonomies: Typical taxonomy that is drag and drop sortable in the normal admin list view and connected to the `stores` post type in the example above.

```
$ptc = new \PE\Post_Types_Creator();
$text_domain = 'text-domain';

$ptc->set_taxonomies(array(
    'area' => array(
        'singular_label' => _x('area', 'Post type singular', $text_domain),
        'plural_label'  => _x('areas', 'Post type plural', $text_domain),
        'description'   => _x('Areas for grouping stores', 'Post type description', $text_domain),
        'post_type'    => 'stores',

        // Make post type drag and drop sortable in admin list view (default: false). Affects all get_terms()-queries
        'sortable'      => true,

        // Override any defaults from register_taxonomy()
        // http://codex.wordpress.org/Function_Reference/register_taxonomy

    )
));

add_action( 'init', array($ptc, 'init'), 0 );
```

##### For more examples, or help to get started see the example plugin in `example/example-plugin.php`. Copy the example plugin to your plugins directory for the fastest way to get started.

[](#for-more-examples-or-help-to-get-started-see-the-example-plugin-in-exampleexample-pluginphp-copy-the-example-plugin-to-your-plugins-directory-for-the-fastest-way-to-get-started)

\##Documentation

### Adding features to post types from core or other plugins

[](#adding-features-to-post-types-from-core-or-other-plugins)

Example for adding sortable to WooCommerce product categories

```
$ptc->set_taxonomies(array(
    'product_cat' => array(
        'register'      => false,
        'post_type'     => array( 'product' ),
        'sortable'      => true,
    ),
));
```

### Labels &amp; description

[](#labels--description)

You only need to send in a singular and a plural version of the post type label, all other labels are automatically generated.

If you want to override something, you can hook into the filter `pe_ptc_post_type_labels` like this:

```
add_filter( 'pe_ptc_post_type_labels',
	function( $generated_args, $post_type_slug, $post_type_args ) {

		// do what you want with $generated_args
		//And then return it back to the plugin
		return $generated_args;
	},
10, 3)
```

```
$post_type['singular_label_ucf'] = ucfirst($post_type['singular_label']);
$post_type['plural_label_ucf'] = ucfirst($post_type['plural_label']);

$generated_args = array(
    'label'               => __( $post_slug, $this->text_domain ),
    'description'         => __( $post_type['plural_label_ucf'], $this->text_domain ),
    'labels'              => array(
        'name'                  => _x( $post_type['plural_label_ucf'], 'Post Type General Name', $this->text_domain ),
        'singular_name'         => _x( $post_type['singular_label_ucf'], 'Post Type Singular Name', $this->text_domain ),
        'menu_name'             => __( $post_type['plural_label_ucf'], $this->text_domain ),
        'parent'                => sprintf(__( 'Parent %s', $this->text_domain ), $post_type['singular_label']),
        //'parent_item_colon'     => sprintf(__( 'Parent %s:', $this->text_domain ), $post_type['singular_label']),
        'all_items'             => sprintf(__( 'All %s', $this->text_domain ), $post_type['plural_label']),
        'view'                  => sprintf(__( 'View %s', $this->text_domain ), $post_type['singular_label']),
        'view_item'             => sprintf(__( 'View %s', $this->text_domain ), $post_type['singular_label']),
        'add_new'               => sprintf(__( 'Add %s', $this->text_domain ), $post_type['singular_label']),
        'add_new_item'          => sprintf(__( 'Add new %s', $this->text_domain ), $post_type['singular_label']),
        'edit'                  => __( 'Edit', $this->text_domain ),
        'edit_item'             => sprintf(__( 'Edit %s', $this->text_domain ), $post_type['singular_label']),
        'update_item'           => sprintf(__( 'Update %s', $this->text_domain ), $post_type['singular_label']),
        'search_items'          => sprintf( __('Search %s', $this->text_domain), $post_type['plural_label']),
        'not_found'             => sprintf(__( 'No %s found', $this->text_domain ), $post_type['plural_label']),
        'not_found_in_trash'    => sprintf(__( 'No %s found in trash', $this->text_domain ), $post_type['plural_label']),
    ),
);
```

### Extra arguments

[](#extra-arguments)

#### admin\_columns

[](#admin_columns)

#### sortable

[](#sortable)

#### Taxonomy filters

[](#taxonomy-filters)

Pass `true` for making filters of all taxonomies for the post type

```
        'taxonomy_filters'               => false,

```

### Overriding `register_post_status()` defaults

[](#overriding-register_post_status-defaults)

All the defaults and arguments that you can pass in to [`register_post_status()`](https://codex.wordpress.org/Function_Reference/register_post_status)

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~107 days

Total

5

Last Release

3336d ago

Major Versions

1.0.1 → 2.0.x-dev2016-08-28

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/680058?v=4)[Peter Elmered](/maintainers/pelmered)[@pelmered](https://github.com/pelmered)

---

Top Contributors

[![pelmered](https://avatars.githubusercontent.com/u/680058?v=4)](https://github.com/pelmered "pelmered (123 commits)")

---

Tags

wordpresscustom-post-typecptcustom-taxonomy

### Embed Badge

![Health badge](/badges/pelmered-post-types-creator/health.svg)

```
[![Health](https://phpackages.com/badges/pelmered-post-types-creator/health.svg)](https://phpackages.com/packages/pelmered-post-types-creator)
```

###  Alternatives

[roots/bedrock

WordPress boilerplate with Composer, easier configuration, and an improved folder structure

6.5k441.8k2](/packages/roots-bedrock)[log1x/poet

Configuration-based post type, taxonomy, editor color palette, block category, and block registration for Sage 10.

218280.1k1](/packages/log1x-poet)[wpbp/cpt_columns

Improve the CPT list in the backend for your CPTs

218.3k](/packages/wpbp-cpt-columns)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
