Bill: WordPress Automatic selection of the previous article selected category directory

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.