我在写作者。php页面,并显示该用户创建的自定义帖子类型。除了分页以外,一切都很好。有人能告诉我我做错了什么吗?谢谢
<?php get_header(); ?>
<?php if (1 == ($paged = (get_query_var(\'paged\') ?: 1))): ?>
<section class="posts-container">
<div class="container">
<h2 style="text-transform: uppercase;">Posts from <?php echo get_the_author_meta( \'display_name\', $author ); ?></h2>
<?php
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
$args = array(
\'post_type\' => array( \'style\' ),
\'post_type\' => array( \'travel\' ),
\'posts_per_page\' => 1000,
\'author\' => $author,
\'paged\'=>$paged,
);
$author_videos = new WP_Query( $args );
if ( $author_videos->have_posts() ) : while ( $author_videos->have_posts() ) : $author_videos->the_post(); ?>
<?php get_template_part(\'partials/single\', \'post\'); ?>
<?php endwhile; ?>
<div class="clear"></div>
<div class="nav-previous alignleft">
<?php next_posts_link( \'Older posts\' ); ?>
</div>
<div class="nav-next alignright">
<?php previous_posts_link( \'Newer posts\' ); ?>
</div>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
</div>
</section>
<?php endif; ?>
SO网友:benny-ben
你已经试过这种方法了吗?
<section class="posts-container">
<div class="container">
<h2 style="text-transform: uppercase;">Posts from <?php echo get_the_author_meta( \'display_name\', $author ); ?></h2>
<?php
$args = array(
\'post_type\' => array( \'style\', \'travel\' ),
\'posts_per_page\' => -1,
\'author\' => $author
);
$author_videos = new WP_Query( $args );
if ( $author_videos->have_posts() ) : while ( $author_videos->have_posts() ) : $author_videos->the_post(); ?>
<?php
// I think you should use archive rather than single
// get_template_part(\'partials/archive\', \'post\');
get_template_part(\'partials/single\', \'post\');
?>
<?php endwhile; ?>
<div class="clear"></div>
<div class="nav-previous alignleft">
<?php next_posts_link( \'Older posts\' ); ?>
</div>
<div class="nav-next alignright">
<?php previous_posts_link( \'Newer posts\' ); ?>
</div>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
</div>
</section>