1. Go to this page and download the library: Download pelmered/post-types-creator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pelmered / post-types-creator example snippets
$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 );
$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' );
}
$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 );
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)