Sometimes we need to publish articles in the same category in succession, and it is cumbersome to re-select each article. Below, we use the program to solve this problem.
Add_action (' Publish_post ', ' SAVE_FL '); Add_action (' admin_footer-post.php ', ' choose_a_category_before_publish '); Add_action (' admin_footer-post-new.php ', ' choose_a_category_before_publish ');functionSAVE_FL ($post _id){ if(Wp_is_post_revision ($post _id ) ) return; Global $current _user; Update_option (' Default_fl_ '.$current _user->id, Json_encode ($_post[' Post_category ']) ); Get_option (' Default_fl_ '.$current _user-ID);}functionChoose_a_category_before_publish () {Global $post _type; Global $current _user; $post _categorys= Json_decode (get_option (' Default_fl_ ').$current _user->id),TRUE); if($post _type= = ' Post '){ ?> <script>JQuery (function($){ <?if(Count($post _categorys) > 0) foreach($post _categorys as $post _category) {?> $("#in-category-<? Echo$post _category;?> "). attr (" Checked "," checked "); <?} ?>});</script><? }}
Bill: WordPress Automatic selection of the previous article selected category directory