博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
黄聪:wordpress自定义post_type,并且自定义固定链接
阅读量:7174 次
发布时间:2019-06-29

本文共 1775 字,大约阅读时间需要 5 分钟。

'招生计划', 'singular_name' => '招生计划', 'add_new' => '添加招生计划', 'add_new_item' => '添加一个新招生计划', 'edit_item' => '编辑招生计划', 'new_item' => '新招生计划', 'view_item' => '查看', 'search_items' => '搜索', 'not_found' => '还没有添加招生计划哦~', 'not_found_in_trash' => '还没有删除的招生计划哦~', 'parent_item_colon' => '', 'menu_name' => '招生计划', 'menu_position' => 5 ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'supports' => array('title','editor','thumbnail','comments','custom-fields'), ); //自定义一个hc_post_type_zsjh的文章类型 register_post_type( 'hc_post_type_zsjh', $args); //自定义固定链接规则 add_action('generate_rewrite_rules',array($this, 'jihua_rewrite_rules') ); } function jihua_rewrite_rules( $wp_rewrite ) { global $wp_rewrite; $wp_rewrite->add_permastruct('hc_post_type_zsjh', '/jihua/%jihua_id%.html', false); $new_rules = array('jihua/([0-9]+)?.html$' => 'index.php?post_type=hc_post_type_zsjh&p=$matches[1]' ); $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } function get_permalink( $permalink, $post, $leavename ) { //替换%jihua_id%为当前文章ID $permalink = str_replace("%jihua_id%", $post->ID, $permalink); return $permalink; }}$zsjh = new zsjh();$zsjh->init();?>

 

转载于:https://www.cnblogs.com/huangcong/p/4249370.html

你可能感兴趣的文章
安装TOMCAT
查看>>
Linux网络命令
查看>>
-bash: lsof: command not found 解决方法
查看>>
《.NET应用架构设计:原则、模式与实践》新书博客--试读-2.1.2 设计原则实战
查看>>
大家技术探讨
查看>>
使用Myeclipse自带的xFire来实现WebService
查看>>
《UNIX环境高级编程》apue.h 头文件的问题
查看>>
系统分析师证书求挂靠,请联系qq 369681392
查看>>
ubuntu中root与user相互切换
查看>>
互联网络解剖
查看>>
大话WEB前端性能优化基本套路
查看>>
初识webservice 服务
查看>>
ASP.NET MVC(二)
查看>>
Ext JS 4.1 RC2 Released发布
查看>>
[转载]2012 年 4 月,rating排行榜
查看>>
(转载)Http 请求处理流程
查看>>
GetVersion和GetVersionEx
查看>>
软工实践第一次作业
查看>>
php采集利器snoopy应用技巧
查看>>
java事件处理机制(自定义事件)j
查看>>