简体   繁体   中英

How do I get articles with a custom post status to display when clicking the All link in the WordPress admin panel?

I have created a custom post status in WordPress using the code below (in functions.php). The reason for this is that our website has 2 editors, and we need a way to show when an article is pending review by the editor-in-chief (the default WordPress "Pending" option will only be used when an article is pending review by the blog editor, who is second-in-command to the editor-in-chief).

My problem is that the articles that are set to the new status don't show up when you select the "All" link at the top of the Posts page in the WordPress admin panel. All the other posts appear except the ones with the new status. There is a new link at the top of the page to display just the articles with the new status, and that works correctly, but how can I get these articles to also show up when clicking on the All link?

// Register Custom Status
function custom_post_status() {

$args = array(
    'label'                     => _x( 'PendingLuke', 'Status General Name', 'text_domain' ),
    'label_count'               => _n_noop( 'PendingLuke (%s)',  'Pending Luke (%s)', 'text_domain' ), 
    'public'                    => false,
    'show_in_admin_all_list'    => true,
    'show_in_admin_status_list' => true,
    'exclude_from_search'       => true,
);
register_post_status( 'pendingluke', $args );

}
add_action( 'init', 'custom_post_status', 0 );

function add_to_post_status_dropdown()
{
 ?>
 <script>
  jQuery(document).ready(function($){
     $("select#post_status").append("<option value=\"PendingLuke\" <?php selected('PendingLuke', $post->post_status); ?>>PendingLuke</option>");
  });
 </script>
 <?php
}

add_action( 'post_submitbox_misc_actions', 'add_to_post_status_dropdown');

I have discovered that this is actually a bug in WordPress itself: https://core.trac.wordpress.org/ticket/24415

The temporary workaround is to add protected => true to the custom post status.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM