wearenolte/wp-cpt

Create custom post types easier.

1.0.4 2021-12-16 15:46 UTC

This package is auto-updated.

Last update: 2024-12-22 01:36:10 UTC


README

This library will allow you to create more easily custom post types for wordpress without too much effort.

Installation

The easiest way to install this package is by using composer from your terminal:

composer require wearenolte/wp-cpt

Or by adding the following lines on your composer.json file

"require": {
  "wearenolte/wp-cpt": "dev-master"
}

This will download the file from the packagist site and the latest version located on master branch of the repository.

After that you can need to include the autoload.php file in order to be able to autoload the class during the object creation.

include '/vendor/autoload.php';

Then you only need to create a new Cpt object with the required params for your custom post type, if you are using the library in a theme you might need to add the function in the init action as an example:

add_action( 'init', function() {
    $testimonials = new \Lean\Cpt([
        'singular' => 'Testimonial',
        'plural' => 'Testimonials',
        'post_type' => 'testimonials',
        'slug' => 'testimonial',
    ]);
    $testimonials->init();
});

The example above allow you to create a new testimonial post type on your theme.