新聞中心
WordPress文章發(fā)布提示用戶(hù)選擇分類(lèi)
通過(guò)WordPress開(kāi)源程序搭建的網(wǎng)站占全球網(wǎng)站的10%,而WordPress官方網(wǎng)站的每月獨(dú)立訪問(wèn)用戶(hù)數(shù)則達(dá)到3億。這串美妙的數(shù)據(jù)可以看出WordPress廣受全球站長(zhǎng)厚愛(ài),但是有一些操作上面的設(shè)計(jì)無(wú)憂主機(jī)小編認(rèn)為非常不人性化,例如:站長(zhǎng)在后臺(tái)撰寫(xiě)文章,常常會(huì)忘記選擇分類(lèi)。在默認(rèn)情況下,如果發(fā)布文章時(shí)沒(méi)有選擇分類(lèi),文章就會(huì)被自動(dòng)歸類(lèi)到“默認(rèn)文章分類(lèi)目錄”這種情況相信大家經(jīng)常發(fā)生。今天無(wú)憂主機(jī)小編將給大家分享一下,當(dāng)發(fā)布文章時(shí)未選擇分類(lèi),就會(huì)顯示一個(gè)提示信息。相信實(shí)現(xiàn)這個(gè)功能站長(zhǎng)們都會(huì)拍掌交好。 實(shí)現(xiàn)WordPress文章發(fā)布提示用戶(hù)選擇分類(lèi)功能操作步驟如下: (注意:以下代碼默認(rèn)只支持文章(post),見(jiàn)第5行的 if($post_type=='post') 就是判讀) 1、FTP工具連接php空間 2、將下列代碼插入當(dāng)前使用WordPress主題文件目錄內(nèi)文件名:functions.php
add_action('admin_footer-post.php', 'choose_a_category_before_publish'); add_action('admin_footer-post-new.php', 'choose_a_category_before_publish'); function choose_a_category_before_publish(){ global $post_type; if($post_type=='post'){ echo "<script> jQuery(function($){ $('#publish, #save-post').click(function(e){ if($('#taxonomy-category input:checked').length==0){ alert('抱歉,發(fā)布文章前,請(qǐng)選擇一個(gè)分類(lèi)'); e.stopImmediatePropagation(); return false; }else{ return true; } }); var publish_click_events = $('#publish').data('events').click; if(publish_click_events){ if(publish_click_events.length>1){ publish_click_events.unshift(publish_click_events.pop()); } } if($('#save-post').data('events') != null){ var save_click_events = $('#save-post').data('events').click; if(save_click_events){ if(save_click_events.length>1){ save_click_events.unshift(save_click_events.pop()); } } } }); </script>"; } }無(wú)憂主機(jī)相關(guān)文章推薦閱讀: WORDPRESS 3.5如何快速添加友情鏈接 WORDPRESS代碼實(shí)現(xiàn)限制上傳圖片的尺寸大小 WORDPRESS程序如何快捷去除后臺(tái)標(biāo)題的-WORDPRESS字樣
本文地址:http://www.love62.cn/wordpress/19812.html
![1](/wp-content/themes/starow_z/img/o-1.png)
![1](/wp-content/themes/starow_z/img/o-2.png)
![1](/wp-content/themes/starow_z/img/o-3.png)
![1](/wp-content/themes/starow_z/img/o-4.png)
![1](/wp-content/themes/starow_z/img/o-5.png)
![1](/wp-content/themes/starow_z/img/o-6.png)
![1](/wp-content/themes/starow_z/img/o-7.png)