簡體   English   中英

單擊WordPress管理面板中的“全部”鏈接時,如何顯示具有自定義帖子狀態的文章?

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

我已經使用以下代碼(在functions.php中)在WordPress中創建了自定義帖子狀態。 原因是我們的網站有2位編輯者,我們需要一種方法來顯示文章何時由總編輯審閱(默認的WordPress“待審”選項僅在文章待審時使用)由主編的第二名博客編輯)。

我的問題是,當您在WordPress管理面板的“帖子”頁面頂部選擇“全部”鏈接時,設置為新狀態的文章不會顯示。 除了具有新狀態的帖子,其他所有帖子都會顯示。 頁面頂部有一個新鏈接,可以僅顯示具有新狀態的文章,並且該鏈接可以正常工作,但是單擊“全部”鏈接時如何顯示這些文章?

// 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');

我發現這實際上是WordPress本身的錯誤: https : //core.trac.wordpress.org/ticket/24415

臨時解決方法是在自定義帖子狀態中添加protected => true。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM