WordPress 自定义文章类型(Post Type)终极指南

http://blog.wpjam.com/article/wordpress-post-type/


<?php 



function my_custom_post_course() {
  $labels = array(
    'name'               => _x( 'course', 'post type 名称' ),
    'singular_name'      => _x( 'course', 'post type 单个 item 时的名称,因为英文有复数' ),
    'add_new'            => _x( '新建课程', '添加新内容的链接名称' ),
    'add_new_item'       => __( '添加一个课程' ),
    'edit_item'          => __( '编辑课程' ),
    'new_item'           => __( '新课程' ),
    'all_items'          => __( '所有课程' ),
    'view_item'          => __( '查看课程' ),
    'search_items'       => __( '搜索课程' ),
    'not_found'          => __( '没有找到有关课程' ),
    'not_found_in_trash' => __( '回收站里面没有相关课程' ),
    'parent_item_colon'  => '',
    'menu_name'          => 'course'
  );
  $args = array(
    'labels'        => $labels,
    'description'   => '我们网站的课程信息',
    'public'        => true,
    'menu_position' => 5,
    'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
    'has_archive'   => true
  );
  register_post_type( 'course', $args );
}
add_action( 'init', 'my_custom_post_course' );




  ?>




<?
  function my_taxonomies_course() {
  $labels = array(
    'name'              => _x( '课程分类', 'taxonomy 名称' ),
    'singular_name'     => _x( '课程分类', 'taxonomy 单数名称' ),
    'search_items'      => __( '搜索课程分类' ),
    'all_items'         => __( '所有课程分类' ),
    'parent_item'       => __( '该课程分类的上级分类' ),
    'parent_item_colon' => __( '该课程分类的上级分类:' ),
    'edit_item'         => __( '编辑课程分类' ),
    'update_item'       => __( '更新课程分类' ),
    'add_new_item'      => __( '添加新的课程分类' ),
    'new_item_name'     => __( '新课程分类' ),
    'menu_name'         => __( '课程分类' ),
  );
  $args = array(
    'labels' => $labels,
    'hierarchical' => true,
  );
  register_taxonomy( 'movie_course', 'course', $args );
}
add_action( 'init', 'my_taxonomies_course', 0 );

?>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值