Skip to content

Hi You, I am Tade

  • About
  • Donate
  • Privacy policy
    • About
    • Donate
    • Privacy policy

Thêm icon khi tạo custom post types trong wordpress

  • Hoàng Thức
  • Jan 19, 2016

Khi bạn tạo một custom post mới ta sẽ thấy icon mặc định của wordpress là icon giống như bài viết. Hôm nay mình sẽ hướng dẫn cách thay đỗi icon mặc định custom post type.

Đầu tiên và cũng nhanh nhất là sữ dụng plugin. Một vài plugin có thể dùng như là:

CPT Custom Icon bạn chỉ cần vào cài đặt và chọn thôi.

screenshot-2

 

Custom Post Type UI  Bạn có thể dùng plugin này tạo và quản lý custom post types.

adding-font-icon-cpt-ui
Wordpress hỗ trợ 1 thư viện icon cho bạn lựa chọn bạn có thể vào link Dashicons website để tìm.

Cách 2 dùng code thêm vào trong custom post. Bạn sẽ dùng đoạn code sau:


	'menu_icon'           => 'dashicons-cart',

Bạn cũng có thể sử dung đoạn url icon


'menu_icon'           => 'http://www.example.com/wp-content/uploads/2014/11/your-cpt-icon.png',

Đoạn code tạo custom post với menu icon

// Register Custom Post Type
function custom_post_type() {

	$labels = array(
		'name'                => _x( 'products', 'Post Type General Name', 'text_domain' ),
		'singular_name'       => _x( 'Product', 'Post Type Singular Name', 'text_domain' ),
		'menu_name'           => __( 'Products', 'text_domain' ),
		'parent_item_colon'   => __( 'Parent Item:', 'text_domain' ),
		'all_items'           => __( 'All Items', 'text_domain' ),
		'view_item'           => __( 'View Item', 'text_domain' ),
		'add_new_item'        => __( 'Add New Item', 'text_domain' ),
		'add_new'             => __( 'Add New', 'text_domain' ),
		'edit_item'           => __( 'Edit Item', 'text_domain' ),
		'update_item'         => __( 'Update Item', 'text_domain' ),
		'search_items'        => __( 'Search Item', 'text_domain' ),
		'not_found'           => __( 'Not found', 'text_domain' ),
		'not_found_in_trash'  => __( 'Not found in Trash', 'text_domain' ),
	);
	$args = array(
		'label'               => __( 'Products', 'text_domain' ),
		'description'         => __( 'Post Type Description', 'text_domain' ),
		'labels'              => $labels,
		'supports'            => array( ),
		'taxonomies'          => array( 'category', 'post_tag' ),
		'hierarchical'        => false,
		'public'              => true,
		'show_ui'             => true,
		'show_in_menu'        => true,
		'show_in_nav_menus'   => true,
		'show_in_admin_bar'   => true,
		'menu_position'       => 5,
		'menu_icon'           => 'dashicons-cart'
		'can_export'          => true,
		'has_archive'         => true,
		'exclude_from_search' => false,
		'publicly_queryable'  => true,
		'capability_type'     => 'page',
	);
	register_post_type( 'Products', $args );

}

// Hook into the 'init' action
add_action( 'init', 'custom_post_type', 0 );

Chúc các bạn thành công !

 

 

 

 

 

    Tags:
  • Thủ thuật wordpress
    Share

Post navigation

←Previous:
Next:→

46 thoughts on “Thêm icon khi tạo custom post types trong wordpress”

  1. dbk viet nam says:
    17 April, 2016 at 2:51 am

    I think this is among the most important info
    for me. And i am glad reading your article. But want
    to remark on some general things, The web site style is perfect, the articles is
    really great : D. Good job, cheers

  2. cờ lê lực says:
    19 April, 2016 at 7:33 am

    I was recommended this web site by my cousin.
    I’m not sure whether this post is written by him as no one else know such detailed about my problem.
    You are wonderful! Thanks!

  3. Pingback: ลวดสลิง
  4. Pingback: Angthong National Marine Park
  5. Pingback: read
  6. Pingback: resource
  7. Pingback: โคมไฟ
  8. Pingback: นำเข้าสินค้าจากจีน
  9. Pingback: ปั้มฟอล
  10. Pingback: สล็อตเว็บตรง
  11. Pingback: ชอบหีสวย.com
  12. Pingback: รับออกแบบร้าน
  13. Pingback: steenslagfolie
  14. Pingback: เรียนต่อออสเตรเลีย
  15. Pingback: ส่งพัสดุ
  16. Pingback: cherry gaming
  17. Pingback: JBO Thai เว็บพนันถูกกฎหมาย
  18. Pingback: arena breakout infinite cheats
  19. Pingback: dark168
  20. Pingback: รับทำ SEO
  21. Pingback: track location by phone number
  22. Pingback: Konya Seo Uzmanı
  23. Pingback: Buy instagram followers
  24. Pingback: web sitesi kurma
  25. Pingback: ทำความรู้จักค่ายสล็อต RICH88
  26. Pingback: football skills
  27. Pingback: cristiano ronaldo skills
  28. Pingback: ป้ายแท็ก
  29. Pingback: strattera 40 mg
  30. Pingback: อัตราการจ่ายเงินของหวยออนไลน์ เว็บ ให้หวย
  31. Pingback: เช่ารถตู้พร้อมคนขับ
  32. Pingback: tga168
  33. Pingback: cam models
  34. Pingback: Info
  35. Pingback: ของเล่นสนาม
  36. Pingback: โกดังเช่า ราคาถูก
  37. Pingback: Nova88max ทางเข้าแทงบอล
  38. Pingback: Lowara distributor water pump
  39. Pingback: KC9 คาสิโนออนไลน์ อันดับ 1
  40. Pingback: Learn more
  41. Pingback: สูตรสล็อตแม่นยํา
  42. Pingback: บริหารสต็อกสินค้าแบบครบวงจร
  43. Pingback: เว็บหวยออนไลน์ จ่ายจริง เว็บตรง LSM99 เว็บตัวมัม
  44. Pingback: diaphragm pump
  45. Pingback: ร้านเค้กวันเกิดใกล้ฉัน
  46. Pingback: lsm99 love เว็บพนันออนไลน์ ครบวงจร

Comments are closed.

©2025 Hi You, I am Tade / Designed & Built by WPFound