您可以使用$user_id = get_current_user_id();
并使用$user_id
在您的查询中。
$user_id = get_current_user_id();
$loop = new WP_Query( array( \'post_type\' => \'html5-blank\', \'category_name\' => \'chapter\', \'author\' => $user_id ) );
if ( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="pindex">
<div class="ptitle">
<h2><?php echo get_the_title(); ?></h2>
</div>
<!-- post thumbnail -->
<div class="featured-image">
<?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_post_thumbnail(array(120,120)); // Declare pixel size you need inside the array ?>
</a>
<?php endif; ?>
</div>
<!-- /post thumbnail -->
<div class="post-content">
<?php the_content(); ?>
</div>
</div>
<?php endwhile;
endif;
wp_reset_postdata();