标题 | WordPress 内容类型名称重命名方法 |
内容 | 对dedecms了解的朋友们,想必对如何获取上一篇、下一篇文章的标签也是非常熟悉。dedecms获取上一篇、下一篇文章的标签分别为:{dede:prenext get='pre'/}、{dede:prenext get='next'}。 在这个标签里,并没有设置上一篇、下一篇文章标题字数的功能,那么我们又该怎样来实现这样的功能呢?其实,dedecms系统这点也做得很好,考虑的也挺周到,这个是可以设置的。WordPress系统源于一个blog平台,慢慢地发展到今天的这样一个功能强大的cms系统! 尽管如此,但是wordpress默认情况下文章页英文叫post, page,有时候,我们开发的时候,也许并不想要这个菜单还是显示着post,和page,也许你想要显示为其它的名称,比如“产品”,”联系人”亦或是其它的名称! 当然我们可以自己写一个post type,移除原来的文章类型,新建的的内容类型可以自己命名,但是其实我们还有一个更好的方法对原来系统的内容类型菜单名称进行重命名: 看下面的一个国外的高手的代码: <?php function change_post_menu_label() { global $menu; global $submenu; $menu[5][0] = 'Contacts'; $submenu['edit.php'][5][0] = 'Contacts'; $submenu['edit.php'][10][0] = 'Add Contacts'; $submenu['edit.php'][15][0] = 'Status'; // Change name for categories $submenu['edit.php'][16][0] = 'Labels'; // Change name for tags echo ''; } function change_post_object_label() { global $wp_post_types; $labels = &$wp_post_types['post']->labels; $labels->name = 'Contacts'; $labels->singular_name = 'Contact'; $labels->add_new = 'Add Contact'; $labels->add_new_item = 'Add Contact'; $labels->edit_item = 'Edit Contacts'; $labels->new_item = 'Contact'; $labels->view_item = 'View Contact'; $labels->search_items = 'Search Contacts'; $labels->not_found = 'No Contacts found'; $labels->not_found_in_trash = 'No Contacts found in Trash'; } add_action( 'init', 'change_post_object_label' ); add_action( 'admin_menu', 'change_post_menu_label' ); To change the menu order, go with this: // CUSTOMIZE ADMIN MENU ORDER function custom_menu_order($menu_ord) { if (!$menu_ord) return true; return array( 'index.php', // this represents the dashboard link 'edit.php', //the posts tab 'upload.php', // the media manager 'edit.php?post_type=page', //the posts tab ); } add_filter('custom_menu_order', 'custom_menu_order'); add_filter('menu_order', 'custom_menu_order'); ?> 这一个代码中就是把原来的文章post的菜单名“post”更改为Contact了! 参考资料:http://wordpress.stackexchange.com/questions/9211/changing-admin-menu-labels dedecms设置上一篇、下一篇文章标题字数的方法: 第一步:找到dedecms下“include/arc.archives.class.php”文件,用DW或记事本打开。 第二步:查找 $this->PreNext['pre']="上一篇:{$preRow['title']}"; 在这一行上面加上 $preRow['title']=cn_substr($preRow['title'],30); ,30的意思就是30个字节,也就是15个汉字。这个可以根据实际情况,自行设定。 第三步:查找 $this->PreNext['next']="下一篇:{$nextRow['title']}"; 在这一行上面加上 $nextRow['title']=cn_substr($nextRow['title'],30); 。 然后保存一下,至此,dedecms设置上一篇、下一篇文章标题字数的方法就完成了。怎么样,简单吧,如果你还在为这个犯愁,那就赶紧试试吧! |
随便看 |
|
在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。