wordpress 內容類型名稱重命名方法

字號:


    對dedecms了解的朋友們,想必對如何獲取上一篇、下一篇文章的標簽也是非常熟悉。dedecms獲取上一篇、下一篇文章的標簽分別為:{dede:prenext get='pre'/}、{dede:prenext get='next'}。
    在這個標簽里,并沒有設置上一篇、下一篇文章標題字數(shù)的功能,那么我們又該怎樣來實現(xiàn)這樣的功能呢?其實,dedecms系統(tǒng)這點也做得很好,考慮的也挺周到,這個是可以設置的。wordpress系統(tǒng)源于一個blog平臺,慢慢地發(fā)展到今天的這樣一個功能強大的cms系統(tǒng)!
    盡管如此,但是wordpress默認情況下文章頁英文叫post, page,有時候,我們開發(fā)的時候,也許并不想要這個菜單還是顯示著post,和page,也許你想要顯示為其它的名稱,比如“產(chǎn)品”,”聯(lián)系人”亦或是其它的名稱!
    當然我們可以自己寫一個post type,移除原來的文章類型,新建的的內容類型可以自己命名,但是其實我們還有一個更好的方法對原來系統(tǒng)的內容類型菜單名稱進行重命名:
    看下面的一個國外的高手的代碼:
    <?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設置上一篇、下一篇文章標題字數(shù)的方法:
    第一步:找到dedecms下“include/arc.archives.class.php”文件,用dw或記事本打開。
    第二步:查找 $this->prenext['pre']=上一篇:{$prerow['title']}; 在這一行上面加上 $prerow['title']=cn_substr($prerow['title'],30); ,30的意思就是30個字節(jié),也就是15個漢字。這個可以根據(jù)實際情況,自行設定。
    第三步:查找 $this->prenext['next']=下一篇:{$nextrow['title']}; 在這一行上面加上 $nextrow['title']=cn_substr($nextrow['title'],30); 。
    然后保存一下,至此,dedecms設置上一篇、下一篇文章標題字數(shù)的方法就完成了。怎么樣,簡單吧,如果你還在為這個犯愁,那就趕緊試試吧!