Học WordPress + AI / WordPress cho người VIỆT !
WPShare247

Học wordpress cho người mới bắt đầu

  • Bắt đầu
    • Học WordPress
    • Elementor
    • WooCommerce
    • Tạo WordPress
    • Học WordPress kiểu mới 2025
    • Học PHP cơ bản
    • Tạo Website bằng WordPress
    • Quản trị WordPress
    • Sửa lỗi WordPress
    • Theme wordpress
    • Plugin WordPress
    • Hàm PHP
    • Seo WordPress
    • Bảo mật WordPress
    • Html & Css
    • Javascript và jQuery
    • Hướng dẫn lập trình
  • Video
    • Video TikTok
    • Video Shorts
  • Kho plugin
  • Kho Prompt
  • Tải Web Miễn Phí
  • Công cụ
    • Kiểm tra web WordPress
    • WordPress theme gì?
    • Check IP Website
    • Kiểm tra Tên Miền
    • Kiểm Tra SSL
    • Tạo File Disavow Google
    • Tạo QR Code
  • Giới thiệu
    • Khuyến Mãi
  • Đăng nhập
X
☰

Trang chủ » Hướng dẫn tạo danh sách Custom Post Type – WordPress Tutorial

Hướng dẫn tạo danh sách Custom Post Type – WordPress Tutorial

Ngày đăng: Xem: 1205
Headless WordPress + Next.js + WPGraphQL – Phần 02 08/03/2026 Xem: 4

Headless WordPress + Next.js + WPGraphQL – Phần 02

Headless WordPress + Next.js + WPGraphQL – Phần 01 20/02/2026 Xem: 78

Headless WordPress + Next.js + WPGraphQL – Phần 01

Quy trình các bước kiểm tra mã độc định kỳ website WordPress 25/01/2026 Xem: 59

Quy trình các bước kiểm tra mã độc định kỳ website WordPress

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' );

 

Shares
ChatGPT ChatGPT
Share
Share
Pin
Về WPShare247

Học wordpress cho người mới bắt đầu.

WPShare247 là blog chia sẻ các kiến thức về WordPress, sửa chữa lỗi wordpress, giới thiệu theme và plugin wordpress mới nhất. Đào tạo khóa học thiết kế Website bằng WordPress.

Menu
  • Trang chủ
  • Giới thiệu
  • Blog
  • Plugin WordPress
  • Liên hệ
Chủ đề wordpress
  • Sửa lỗi WordPress
  • Plugin WordPress
  • Theme wordpress
  • Seo WordPress
  • WooCommerce

Copyright © 2026 WPSHARE247. All Rights Reserved.
Một sản phẩm của WEB 366

  • Thiết kế web bởi Website366.com
  • Thiết kế website chuyên nghiệp TBAY.VN
  • Thiết kế WEB AI