使用 register_post_status() 在 WordPress 创建自定义文章状态

Posted in:
Update time:2017-11-27

We offer WordPress Themes and Plugins Custom Development Services

This site has long undertaken WordPress themes, plugins, WooCommerce-based store mall development business. We have 10 years of experience in WordPress development, if you want to Developing Websites with WordPress, please contact WeChat: iwillhappy1314 or email: amos@wpcio.com for inquiries.

4 thoughts on “使用 register_post_status() 在 WordPress 创建自定义文章状态

    1. 这个我没有测试过,不过 WordPress 向后兼容性是很好的,已经有的功能不会轻易移除,所以,理论上这个方法在 WordPress 4.9 中是可以使用的。

      1. 你好,但是我使用,文章所说的,在文章编辑页增添新状态的选项的代码

        add_action('admin_footer-post.php', 'wizhi_append_post_status_list');
        function wizhi_append_post_status_list(){
             global $post;
             $complete = '';
             $label = '';
             if($post->post_type == 'post'){
                  if($post->post_status == 'archive'){
                       $complete = ' selected="selected"';
                       $label = 'Archive';
                  }
                  echo '
                  
                  jQuery(document).ready(function($){
                       $("select#post_status").append("Archive");
                       $(".misc-pub-section label").append("'.$label.'");
                  });
                  
                  ';
             }
        }

        发现并没有出现新的选项

发表回复

Your email address will not be published. 必填项已用 * 标注

*