Download the PHP package pelmered/post-types-creator without Composer
On this page you can find all versions of the php package pelmered/post-types-creator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pelmered/post-types-creator
More information about pelmered/post-types-creator
Files in pelmered/post-types-creator
Package post-types-creator
Short Description Helper plugin for easily creating localize-ready custom post types and custom taxonomies in WordPress
License GPL-2.0+
Homepage https://github.com/pelmered/Post-types-creator
Informations about the package post-types-creator
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
- Planned features
- Common problems & troubleshooting
- Installation
- Composer
- Normal manual install
- Use the example plugin as a boilderplate for your custom post type plugin
- Usage
- Adding custom post types
- Minimal:
- Example / typical:
- Adding taxonomies:
- 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()
andregister_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 & 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 & 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:
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).
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).
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.
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.
Documentation
Adding features to post types from core or other plugins
Example for adding sortable to WooCommerce product categories
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:
Extra arguments
admin_columns
sortable
Taxonomy filters
Pass true
for making filters of all taxonomies for the post type
'taxonomy_filters' => false,
Overriding register_post_status()
defaults
All the defaults and arguments that you can pass in to register_post_status()