2017 © Pedro Peláez
 

library wp-custom-content

A library that generates WordPress custom post types and taxonomies from a config file.

image

carawebs/wp-custom-content

A library that generates WordPress custom post types and taxonomies from a config file.

  • Saturday, April 1, 2017
  • by DavidEgan
  • Repository
  • 1 Watchers
  • 0 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

WP CPT

A WordPress plugin which registers:, (*1)

  • Custom post types
  • Custom taxonomies

If you want to use this as a Composer package, rather than as a WordPress plugin, use the dev-library branch:, (*2)

// composer.json for project
"carawebs/wp-custom-content": "dev-library"

I don't recommend this - the dev-library is a bit of an experiment in de-coupling custom post type registration from themes and plugins and is probably a step too far. CPT registration is probably best managed in either a plugin or mu-plugin). That branch does have quite an interesting method of loading, and a fluent interface to set the config file location., (*3)

Usage

This plugin is designed for use with Bedrock. Bedrock has an improved project structure compared to regular WordPress installations., (*4)

The plugin is intended as an aid for developers - there is no settings GUI., (*5)

Instead, a configuration file which returns a PHP array is used to register custom post types and taxonomies. This means you can easily define custom post types and taxonomies for your project by simply amending an array., (*6)

Config Files

Sample config files are provided in the /sample-config directory., (*7)

By default, the plugin looks for config files in the config directory. You could amend this - which is outside the document root for the project. If you're using a regular WordPress installation, you may need to fork this plugin and modify the path to the config files:, (*8)

<?php
// See: `/custom-content.php`
$path = dirname(ABSPATH, 2) . '/config/';
// Define the path to the config file for CPTs:
define('CARAWEBS_CUSTOM_CONTENT_CONFIG', $path . 'cpt-config.php');
// Define the path for the config file for custom taxonomies:
define('CARAWEBS_CUSTOM_TAX_CONFIG', $path . 'tax-config.php');

The default locations are:, (*9)

  • CPT config: /path/to/example.com/config/cpt-config.php
  • Custom taxonomy config: /path/to/example.com/config/tax-config.php

If you're working in Bedrock and want to quickly copy across the sample config files, run this from the plugin root directory:, (*10)

# At terminal/BASH prompt
cp sample-config/cpt-config.php ../../../../config/cpt-config.php

# More conservatively:
cp sample-config/cpt-config.php path/to/yoursite.com/config/cpt-config.php

To Do

  • Config files should be in YAML format to make them easier to edit.
  • Proper error handling if there is no config file.

The Versions

01/04 2017

dev-library

dev-library

A library that generates WordPress custom post types and taxonomies from a config file.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

25/03 2017

dev-master

9999999-dev

A Wordpress plugin that generates custom post types and taxonomies from a config file.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

25/03 2017

1.0.2

1.0.2.0

A Wordpress plugin that generates custom post types and taxonomies from a config file.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

25/03 2017

1.0.1

1.0.1.0

A Wordpress plugin that generates custom post types and taxonomies from a config file.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

25/03 2017

1.0.0

1.0.0.0

A Wordpress plugin that generates custom post types and taxonomies from a config file.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

15/02 2017

0.3.0

0.3.0.0

A Wordpress plugin that generates custom post types and taxonomies from a config file.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

15/02 2017

v0.2.2

0.2.2.0

A Wordpress plugin that generates custom post types and taxonomies from a config file.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

15/02 2017

v0.2.1

0.2.1.0

A Wordpress plugin that generates custom post types and taxonomies from a config file.

  Sources   Download

MIT

15/02 2017

v0.2

0.2.0.0

A Wordpress mu-plugin that generates custom post types and taxonomies from a config file.

  Sources   Download

MIT

15/02 2017

v0.1

0.1.0.0

A Wordpress mu-plugin that generates custom post types and taxonomies from a config file.

  Sources   Download

MIT