wordpress主题添加专题文章功能

作者: 魏代群 分类: wordpress,技术学习 发布时间: 2020-11-17 14:58

functions.php文件内,就可以实现在wordpress后台添加专题的功能。非常简单,赶快行动起来吧

//新增自定义文章类型:专题
function ws_work() {
register_post_type( ‘work’, //这里的work可以自行修改,主要体现在URL里面
array(
‘labels’ => array(
‘name’ => ‘专题’,
‘singular_name’ => ‘所有专题’,
‘add_new’ => ‘添加专题’,
‘add_new_item’ => ‘添加新专题’,
‘edit’ => ‘编辑’,
‘edit_item’ => ‘编辑专题’,
‘new_item’ => ‘新专题’,
‘view’ => ‘查看专题’,
‘view_item’ => ‘查看专题’,
‘search_items’ => ‘搜索专题’,
‘not_found’ => ‘没有找到相关专题’,
‘not_found_in_trash’ => ‘没有专题评论’,
‘parent’ => ‘专题评论’,
),
‘exclude_from_search’=>false,
‘public’ => true,
‘menu_position’ => 6,
‘supports’ => array( ‘title’, ‘editor’,’comments’, ‘custom-fields’,’thumbnail’,’excerpt’), //为自定义文章添加标题,编辑器,评论,自定义字段,特色图像,摘要功能
‘taxonomies’ => array( ” ), //分类法,我们是单独定义
‘has_archive’ => true,
‘taxonomies’=> array(‘post_tag’), //没有这一句是没有标签功能的
)
);
}
add_action( ‘init’, ‘ws_work’ ); //挂载函数
//为商品类自定义类型增加分类功能
add_action( ‘init’, ‘ws_works’, 0 );
function ws_works() {
register_taxonomy(
‘works’, //这个分类法
‘work’, //这个是自定义文章类型,默认文章是post,其他是你自己定义的
array(
‘labels’ => array(
‘name’ => ‘作品专题’,
‘add_new_item’ => ‘添加专题’,
‘new_item_name’ => “新专题分类”
),
‘show_ui’ => true,
‘show_tagcloud’ => true,
‘hierarchical’ => true,
)
);
}

如果觉得我的文章对您有用,请随意赞赏。您的支持将鼓励我继续创作!

发表评论

电子邮件地址不会被公开。 必填项已用*标注

标签云
Wet penis piss movies gay xxx Poolhouse Pissing Orgy! - gaysex, gay, twinks gayman.cc xvideos.com bb53953fd7797f52bb2c71b189e2dc99 - xvideos.com, bb53953fd7797f52bb2c71b189e2dc99 All male gay porn teacher first time Chained to the warehouse floor - gaysex, twinks, gay Sexo gostoso - gay-amateur, gay, big-dick gayman.cc Sucking delicious str8 hard cock 14 - homo, gay Cop gay dick sex Reagan Fucks & Fists - twinks, gay-fist, gay gayman.cc gayman.cc gayman.cc Sex xxx photo land old daddy men gay porn tube videos He briefly - gay, twinks, twink