File functions.php
<?php require 'backend.php';
Nội dung file backend.php
<?php
/**
* Registers a new post type
* @uses $wp_post_types Inserts new post type object into the list
*
* @param string Post type key, must not exceed 20 characters
* @param array|string See optional args description above.
* @return object|WP_Error the registered post type object, or an error object
*/
function wpshare247_register_name() {
$labels = array(
'name' => __( 'Dịch vụ', 'text-domain' ),
'singular_name' => __( 'Dịch vụ', 'text-domain' ),
'add_new' => _x( 'Add New Dịch vụ', 'text-domain', 'text-domain' ),
'add_new_item' => __( 'Add New Dịch vụ', 'text-domain' ),
'edit_item' => __( 'Edit Dịch vụ', 'text-domain' ),
'new_item' => __( 'New Dịch vụ', 'text-domain' ),
'view_item' => __( 'View Dịch vụ', 'text-domain' ),
'search_items' => __( 'Search Dịch vụ', 'text-domain' ),
'not_found' => __( 'Không tìm thấy Dịch vụ', 'text-domain' ),
'not_found_in_trash' => __( 'Không tìm thấy Dịch vụ', 'text-domain' ),
'parent_item_colon' => __( '', 'text-domain' ),
'menu_name' => __( 'Dịch vụ', 'text-domain' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'description' => 'description',
'taxonomies' => array('dmdv'),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_admin_bar' => true,
'menu_position' => null,
'menu_icon' => 'dashicons-embed-audio',
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => array('slug' => 'dich-vu' ),
'capability_type' => 'post',
'supports' => array(
'title',
'editor',
'author',
'thumbnail',
'excerpt',
'custom-fields',
'trackbacks',
'comments',
'revisions',
'page-attributes',
'post-formats',
),
);
register_post_type( 'wpshare247-dich-vu', $args );
//----------------taxonomy
$labels_dv = array(
'name' => _x( 'Danh mục dv', 'Taxonomy plural name', 'text-domain' ),
'singular_name' => _x( 'Danh mục dv', 'Taxonomy singular name', 'text-domain' ),
'search_items' => __( 'Search Plural Name', 'text-domain' ),
'popular_items' => __( 'Popular Plural Name', 'text-domain' ),
'all_items' => __( 'All Plural Name', 'text-domain' ),
'parent_item' => __( 'Parent Singular Name', 'text-domain' ),
'parent_item_colon' => __( 'Parent Singular Name', 'text-domain' ),
'edit_item' => __( 'Edit Singular Name', 'text-domain' ),
'update_item' => __( 'Update Singular Name', 'text-domain' ),
'add_new_item' => __( 'Add New Singular Name', 'text-domain' ),
'new_item_name' => __( 'New Singular Name Name', 'text-domain' ),
'add_or_remove_items' => __( 'Add or remove Plural Name', 'text-domain' ),
'choose_from_most_used' => __( 'Choose from most used Plural Name', 'text-domain' ),
'menu_name' => __( 'Danh mục dv', 'text-domain' ),
);
$args_dich_vu = array(
'labels' => $labels_dv,
'public' => true,
'show_in_nav_menus' => true,
'show_admin_column' => false,
'hierarchical' => false,
'show_tagcloud' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => array('slug' => 'danh-muc-dich-vu'),
'query_var' => true,
'capabilities' => array(),
);
register_taxonomy( 'tax-dich-vu', array( 'wpshare247-dich-vu' ), $args_dich_vu );
}
add_action( 'init', 'wpshare247_register_name' );