new WP_Query with author argument return no results

Whenever you use capability_type you need to then assign those capabilities to the roles which should have access to the post type; Otherwise they will not have access to the post type.

Awhile back Justin Tadlock wrote an article around capbility_type: Meta Capabilities For Custom Post Types.

If you don’t want to have to assign these capabilities to roles then you can simply change it to 'capability_type' => 'post' or 'capbility_type' => 'page' which will give anyone whoever has access to posts or pages respectively the same access to your post type.


A few things to note:

1) Ensure your post type slug is the same. It may be labelled “Resume” but the slug may be different. Without seeing the post type registration code it’s difficult to say.

2) You need to assign the query to a variable then loop that variable. This is a secondary query which is different the a normal query. You need to loop it yourself. The documentation has some good examples about a standard loop:

https://developer.wordpress.org/reference/classes/wp_query/#standard-loop

<?php 
    // the query
    $the_query = new WP_Query(array(
        'post_type' => 'resume',
        'author' => 1,
    ) );
?>

<?php if ( $the_query->have_posts() ) : ?>

    <!-- the loop -->
    <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
        <h2><?php the_title(); ?></h2>
    <?php endwhile; ?>
    <!-- end of the loop -->

    <!-- Reset the main query data -->
    <?php wp_reset_postdata(); ?>

<?php else : ?>
    <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>

3) Make sure that this is the author you’re looking for. Usually ID 1 is the first author made for the site, like an Administrator.

tech