Wordpress 在状态下拉列表中,注册后状态未显示后状态

Wordpress 在状态下拉列表中,注册后状态未显示后状态,wordpress,Wordpress,我已经检查了stackoverflow中与我的问题相关的所有问题,但仍然没有得到任何答案 我想将自定义帖子状态添加到我的博客帖子中。 我在function.php中添加了以下代码,但在“快速编辑状态”下拉部分和“后期编辑状态”下拉部分中,我无法看到该后期状态 function my_register_post_status() { $my_status_args = array( 'label' => __('Activated', 'my'),

我已经检查了stackoverflow中与我的问题相关的所有问题,但仍然没有得到任何答案


我想将自定义帖子状态添加到我的博客帖子中。 我在function.php中添加了以下代码,但在“快速编辑状态”下拉部分和“后期编辑状态”下拉部分中,我无法看到该后期状态

  function my_register_post_status() {
    $my_status_args = array(
        'label' => __('Activated', 'my'),
        'label_count' => __('Activated', 'my'),
        'exclude_from_search' => false,
        'public' => true,
        'publicly_queryable' => true,
        'show_in_admin_status_list' => true,
        'show_in_admin_all_list' => true,
    );
    register_post_status( 'status', $my_status_args );
}
add_action( 'init', 'my_register_post_status' );
这里我还附上了同样的截图。

您必须添加一些javascript,才能将状态作为选择中的一个选项。请尝试以下方法:

function append_post_status_list() {
        global $post;
        $label    = " Activate";
        $complete = "<option value='activated'>$label</option>";
        if ( $post->post_status == 'activated' ) {
            $label    = " Activated";
            $complete = "<option value='activated' selected='selected'>$label</option>";
        }

        ob_start();
        ?>
        <script>
            jQuery(document).ready(function ($) {
                var label = "<?= $label ?>";
                $("select#post_status").append("<?= $complete ?>");
                if (' Activated' == label){
                    $(".misc-pub-section #post-status-display").html(label);
                }
            });
        </script>
        <?php
        echo ob_get_clean();
}
add_action( 'admin_footer-post.php', 'append_post_status_list' );
函数append\u post\u status\u list(){
全球$员额;
$label=“激活”;
$complete=“$label”;
如果($post->post_status=='activated'){
$label=“已激活”;
$complete=“$label”;
}
ob_start();
?>
jQuery(文档).ready(函数($){
var标签=”;
$(“选择后状态”)。附加(“”);
如果(‘已激活’==标签){
$(“.misc pub section#post status display”).html(标签);
}
});

下面是在快速编辑、发布新页面和发布编辑页面中添加新自定义状态的代码

   function my_custom_status_creation(){
        register_post_status( 'approved', array(
            'label'                     => _x( 'Approved', 'post' ),
            'label_count'               => _n_noop( 'Approved <span class="count">(%s)</span>', 'Approved <span class="count">(%s)</span>'),
            'public'                    => true,
            'exclude_from_search'       => false,
            'show_in_admin_all_list'    => true,
            'show_in_admin_status_list' => true
        ));
    }
    add_action( 'init', 'my_custom_status_creation' );

    function my_custom_status_add_in_quick_edit() {
        echo "<script>
        jQuery(document).ready( function() {
            jQuery( 'select[name=\"_status\"]' ).append( '<option value=\"approved\">Approved</option>' );      
        }); 
        </script>";
    }
    add_action('admin_footer-edit.php','my_custom_status_add_in_quick_edit');
    function my_custom_status_add_in_post_page() {
        echo "<script>
        jQuery(document).ready( function() {        
            jQuery( 'select[name=\"post_status\"]' ).append( '<option value=\"approved\">Approved</option>' );
        });
        </script>";
    }
    add_action('admin_footer-post.php', 'my_custom_status_add_in_post_page');
    add_action('admin_footer-post-new.php', 'my_custom_status_add_in_post_page');
函数我的\自定义\状态\创建(){
注册后状态('approved',数组(
“标签”=>x('Approved','post'),
“标签计数”=>“已批准(%s)”,“已批准(%s)”,
“public”=>正确,
“从搜索中排除”=>false,
“在\u管理\u所有\u列表中显示\u”=>true,
'在\u管理\u状态\u列表中显示\u'=>true
));
}
添加动作('init','my_custom_status_creation');
函数my_custom_status_add_in_quick_edit(){
回声“
jQuery(文档).ready(函数(){
jQuery('select[name=\'“\'”).append('Approved');
}); 
";
}
添加操作('admin\u footer-edit.php'、'my\u custom\u status\u add\u in\u quick\u edit');
函数my_custom_status_add_in_post_page(){
回声“
jQuery(文档).ready(函数(){
jQuery('select[name=\'post\u status\'”)。追加('Approved');
});
";
}
添加操作('admin\u footer-post.php','my\u custom\u status\u add\u in\u post\u page');
添加操作('admin\u footer-post-new.php','my\u custom\u status\u add\u in\u post\u page');
Yes阅读此处的注意事项,这篇文章应该会有所帮助