Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

custom post

if ( ! function_exists('products_post_type') ) {

// Register Custom Post Type
function products_post_type() {

	$labels = array(
		'name'                  => 'محصولات',
		'singular_name'         => 'محصول',
		'menu_name'             => 'محصولات',
		'name_admin_bar'        => 'محصولات',
		'archives'              => 'آرشیو',
		'attributes'            => 'ویژگی‌ها',
		'parent_item_colon'     => 'والد',
		'all_items'             => 'همه محصولات',
		'add_new_item'          => 'افزودن محصول جدید',
		'add_new'               => 'افزودن جدید',
		'new_item'              => 'محصول جدید',
		'edit_item'             => 'ویرایش محصول',
		'update_item'           => 'بروزرسانی محصول',
		'view_item'             => 'مشاهده محصول',
		'view_items'            => 'مشاهده محصولات',
		'search_items'          => 'جستجوی محصول',
		'not_found'             => 'پیدا نشد',
		'not_found_in_trash'    => 'در زباله‌دان پیدا نشد',
		'featured_image'        => 'تصویر شاخص',
		'set_featured_image'    => 'قرار دادن تصویر شاخص',
		'remove_featured_image' => 'حذف تصویر شاخص',
		'use_featured_image'    => 'استفاده به عنوان تصویر شاخص',
		'insert_into_item'      => 'وارد کردن در محصول',
		'uploaded_to_this_item' => 'بارگذاری در این محصول',
		'items_list'            => 'لیست محصولات',
		'items_list_navigation' => 'پیمایش لیست محصولات',
		'filter_items_list'     => 'فیلتر لیست محصولات',
	);
	$rewrite = array(
		'slug'                  => 'products',
		'with_front'            => true,
		'pages'                 => true,
		'feeds'                 => true,
	);
	$args = array(
		'label'                 => 'محصول',
		'description'           => 'Product information pages',
		'labels'                => $labels,
		'supports'              => array( 'title', 'editor', 'thumbnail', 'comments', 'custom-fields', 'page-attributes', 'post-formats' ),
		'taxonomies'            => array( 'my_products_category', 'my_products_brand' ),
		'hierarchical'          => true,
		'public'                => true,
		'show_ui'               => true,
		'show_in_menu'          => true,
		'menu_position'         => 20,
		'menu_icon'             => 'dashicons-products',
		'show_in_admin_bar'     => true,
		'show_in_nav_menus'     => true,
		'can_export'            => true,
		'has_archive'           => true,
		'exclude_from_search'   => false,
		'publicly_queryable'    => true,
		'query_var'             => 'products',
		'rewrite'               => $rewrite,
		'capability_type'       => 'page',
		'show_in_rest'          => true,
	);
	register_post_type( 'my_products', $args );

}
add_action( 'init', 'products_post_type', 0 );

}