PHP code example of jazzman / custom-post-type

1. Go to this page and download the library: Download jazzman/custom-post-type 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/ */

    

jazzman / custom-post-type example snippets



use JazzMan\Post\CustomPostType;

$books = new CustomPostType('book');

$books = new CustomPostType('book', array(
	'supports' => array('title', 'editor', 'thumbnail', 'comments')
));

$blog = new CustomPostType('post');

$books->registerTaxonomy('genres');

$books->registerTaxonomy('genres',array(
	'show_ui'       => true,
	'query_var'     => true,
	'rewrite'       => array( 'slug' => 'the_genre' )
));

$books->setFilters(array('genre'));

$books->setColumns(array(
	'cb' => '<input type="checkbox" />',
	'title' => __('Title'),
	'genre' => __('Genres'),
	'price' => __('Price'),
	'rating' => __('Rating'),
	'date' => __('Date')
));

$books->setPopulateColumns('column_name', function($column, $post) {

	// your code goes here…

});

$books->setPopulateColumns('price', function($column, $post) {

	echo "£" . get_post_meta($post->ID,'price',true);

});

$books->setMenuIcon('dashicons-book-alt');