0
我搜索了互聯網,但找不到解決方案。我收到404錯誤,當我使用WP pagenavi導航到任何其他頁面,找不到頁面錯誤導航
<ul class="product-items">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type'=>'product',
'posts_per_page' => 1,
'paged' => $paged
);
$product_query = new WP_Query($args);
if($product_query->have_posts()) : while($product_query ->have_posts()) : $product_query ->the_post();
$id = get_the_ID();
?>
<li>
<a href="<?php the_permalink(); ?>">
<span class="product-img"><?php echo get_the_post_thumbnail($id, array(101,128,true)) ?></span>
<span class="product-detail"><?php $title=get_the_title(); echo $trimed=wp_trim_words($title,3) ?></span>
</a>
</li>
<?php endwhile; if(function_exists('wp_pagenavi')) { wp_pagenavi(array('query' => $product_query)); }
wp_reset_postdata(); ?>
這個'wp_pagenavi($ product_query);'可能是問題所在。評論一下,看看你是否仍然有錯誤信息。並且避免在方法調用中添加空格,這也可能導致問題('$ product_query - > have_posts()'應該是'$ product_query-> have_posts())'。 – vard
感謝隊友回覆,我不會在刪除wp_pagenavi($ product_query)時出錯。但我也沒有得到導航?我需要導航..我也只是刪除空間 – Habib
我只是找到解決方案,取代wp_pagenavi($ product_query);與wp_pagenavi(數組('查詢'=> $ product_query))但現在我得到404導航.. – Habib