By default Wordpress private posts are visible to all admins right. But on this build for some reason private posts are only displaying (on the page) to the admin that created it. I'm perplexed. I need all admins to see the private posts displayed.

This is a custom post type using a custom query so maybe there's something I did there.

// query upcoming webinars - Sort by date from date Picker
    $args_upcoming = array(
      'cat' => $thiscat_id,
      'numberposts' => -1,
      'orderby' => 'meta_value', 
      'order' => 'ASC',
      'meta_query' => array(
          'key' => 'webinar_date',
          'value' => $query_date,
          'compare' => '>=',
          'type' => 'DATE'
$upcoming_query = new WP_Query( $args_upcoming );

The custom post type settup:

** START--- Custom Post Type Webinars ---*/
function custom_post_type_webinars() {
// Set UI labels for Custom Post Type
    $labels = array(
        'name'                => _x( 'Webinars', 'Post Type General Name', 'twentytwenty' ),
        'singular_name'       => _x( 'Webinar', 'Post Type Singular Name', 'twentytwenty' ),
        'menu_name'           => __( 'Webinars', 'twentytwenty' ),
        'parent_item_colon'   => __( 'Parent Webinar', 'twentytwenty' ),
        'all_items'           => __( 'All Webinars', 'twentytwenty' ),
        'view_item'           => __( 'View Webinar', 'twentytwenty' ),
        'add_new_item'        => __( 'Add New Webinar', 'twentytwenty' ),
        'add_new'             => __( 'Add New', 'twentytwenty' ),
        'edit_item'           => __( 'Edit Webinar', 'twentytwenty' ),
        'update_item'         => __( 'Update Webinar', 'twentytwenty' ),
        'search_items'        => __( 'Search Webinar', 'twentytwenty' ),
        'not_found'           => __( 'Not Found', 'twentytwenty' ),
        'not_found_in_trash'  => __( 'Not found in Trash', 'twentytwenty' ),
// Set other options for Custom Post Type
    $args = array(
        'label'               => __( 'Webinars', 'twentytwenty' ),
        'description'         => __( 'Upcoming Webinars', 'twentytwenty' ),
        'labels'              => $labels,
        'supports'            => array( 'title', 'editor', 'excerpt', 'thumbnail', 'revisions', 'custom-fields', ),
        'hierarchical'        => true,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 5,
        'can_export'          => true,
        'has_archive'         => true,
        'public'              => true,
        'exclude_from_search' => false,
        'publicly_queryable'  => true,
        'capability_type'     => 'post',
        'show_in_rest' => true,
    register_post_type( 'webinars', $args );
add_action( 'init', 'custom_post_type_webinars', 0 );
/** END-- Custom Post Type Webinars --------------*/

Website is https://ibkrwebinars.com/category/webinars-upcoming/

Again: private posts I created display to me. But not to the other admins that are logged in and visa-versa.

  • It's hard to troubleshoot without the code you used to register the CPT. You may want to try using a plugin like User Role Editor to verify that whatever permissions are required to view private CPTs are granted to all admins. If you've used map_meta_cap to create custom permissions then by default no users would have permission to view unless you specifically grant it to them.
    – WebElaine
    Jul 9, 2021 at 14:08
  • What is the code you posted in your question? It looks like an attempt to build an array of arguments to call WP_Query but there are a few problems with it if so.
    – jdm2112
    Jul 9, 2021 at 14:11
  • I've updated the code to include the custom post type. My other Wordpress sites all display the private posts to all admins when logged in. So I'd rather not use a plugin for this if I can help it. The query does work for showing upcoming posts by custom date field. Jul 12, 2021 at 17:30

1 Answer 1


The solution I found is in the pre_get_posts function: I added:

if ( is_user_logged_in() ) {
        $query->set( 'post_status', array('private', 'publish'));

Full code for function:

/*------- START add webinars custom post type to the main query loop----------*/
add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
  if( is_category() ) {
    $post_type = get_query_var('post_type');
    // show private posts to admins too.
    if ( is_user_logged_in() ) {
        $query->set( 'post_status', array('private', 'publish'));
        $post_type = $post_type;
        $post_type = array('nav_menu_item', 'post', 'webinars'); // don't forget nav_menu_item to allow menus to work!
    return $query;
/*------- END add webinars custom post type to the main query loop----------*/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.