[英]How to display custom post for user only in wordpress
我是 wordpress 的新手,我創建了自定義帖子類型,我希望這應該只顯示給訂閱者(而不是管理員)所以我該怎么做這是我當前的代碼? 函數 create_posttype() {
register_post_type( 'UserProject',
array(
'labels' => array(
'name' => __( 'UserProject' ),
'singular_name' => __( 'UserProject' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'UserProject'),
'show_in_rest' => true,
)
);
}
// Hooking up our function to theme setup
add_action( 'init', 'create_posttype' );
if ( current_user_can( 'editor' ) && is_user_logged_in()) { function book_setup_post_type() { $args = array( 'public' => true, 'label' => __( 'Books', 'textdomain' ), 'menu_icon' => 'dashicons-book', ); register_post_type( 'book', $args ); } add_action( 'init', 'book_setup_post_type' ); }
Book 是一種自定義帖子類型,您可以在此處編寫自己的代碼。 訂閱者對儀表板沒有任何權利。 您可以為編輯器規則或其他規則設置條件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.