【发布时间】:2015-11-13 09:19:09
【问题描述】:
我需要为我正在处理的项目提取两种自定义帖子类型。我将它们作为数组传递给 post_type。在前面,它们分为两个不同的列表类别,微笑和广告。他们出现了,但是分页中断了。我已经使用 %postname% 设置了我的永久链接,编辑了 Page navi 的设置,但仍在阅读 404。
url 应该读为 /smiles/page/*/,他们这样做,但读为 404。
这是代码。
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$the_query = new WP_Query( array(
'post_type' => array ('smiles','ads'),
'order' => 'DESC',
'posts_per_page' =>'3',
'paged' => $paged ));
while ( $the_query->have_posts() ) : $the_query->the_post();
?>
<?php if ($post->post_type == 'smiles') { ?>
<li class=smile>
<h3><?php the_author(); ?></h3>
<a href="<?php the_permalink(); ?>" class=x-fi><img src="<?php echo get_first_image(); ?>" /></a>
<p><?php the_excerpt(); ?></p>
<?php echo getPostLikeLink( get_the_ID() ); ?>
<a href="<?php the_permalink(); ?>">Read More / Comment...</a>
</li>
<?php } ?>
<?php if ($post->post_type == 'ads') { ?>
<li class=ad>
<?php the_content(); ?>
</li>
<?php } ?>
<?php endwhile; ?>
</ul>
<?php wp_pagenavi( array( 'query' => $the_query ) ); wp_reset_query(); ?>
编辑 1:
查看了一些帖子。将 $the_query 更改为 $wp_query,但没有结果。
【问题讨论】:
-
您是否尝试过重新保存永久链接codex.wordpress.org/Settings_Permalinks_Screen?
-
是的。我将它们切换为默认值,然后又返回。
标签: php pagination wordpress