我正在尝试创建一个 author.php 页面,该页面由出现在该页面上的作者调用自定义帖子类型。我的问题是,当使用下面的代码时——过滤帖子类型“视频”——代码输出所有自定义帖子类型,而不仅仅是“视频”。需要注意的是,当我删除数组的作者键和变量时'author' => $author
,它们的效果是允许代码输出所需的自定义帖子类型“视频”,但来自每个作者。关于如何解决这个问题的任何想法?
使用的代码:
<?php
$args = array(
'post_type' => array( 'audio' ),
'posts_per_page' => 10,
'author' => $author
);
$author_videos = new WP_Query( $args );
if ( $author_videos->have_posts() ) : while ( $author_videos->have_posts() ) : $author_videos->the_post(); ?>
<p><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></p>
<?php endwhile;
wp_reset_postdata();
endif; ?>