PHP code example of web-soldier / wp-post-type-util

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

    

web-soldier / wp-post-type-util example snippets


/**
 * Register post type example.
 *
 * Author: NikolayS93
 * License: GNU General Public License v2 or later
 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
 */

use WP_Utility\Post_Type;
use WP_Utility\Custom_Fields_Meta_Box;



// Register new post type.
$post_type = new Post_Type( 'slide', $args = array(), array(
	'name'               => __( 'Слайды' ),
	'singular_name'      => __( 'Слайд' ),
	'add_new'            => __( 'Добавить слайд' ),
	'add_new_item'       => __( 'Добавить слайд' ),
	'edit_item'          => __( 'Редактировать слайд' ),
	'new_item'           => __( 'Новый слайд' ),
	'all_items'          => __( 'Все слайды' ),
	'view_item'          => __( 'Просмотр слайда на сайте' ),
	'search_items'       => __( 'Найти слайд' ),
	'not_found'          => __( 'Слайдов не найдено.' ),
	'not_found_in_trash' => __( 'В корзине нет слайдов.' ),
	'menu_name'          => __( 'Слайды' ),
) );

// Add metabox with custom meta fields on edit page.
$post_type
	->set_metabox( new Custom_Fields_Meta_Box( array(
		'link' => __( 'Ссылка' ),
	) ) );