【发布时间】:2022-01-16 04:55:44
【问题描述】:
我有这个 search.php 以及按年份/类型搜索的结果:
<?php get_header();
$loop = new TOROFLIX_Movies();
$sidebar_position = $loop->sidebar_position('sidebar_type_category'); ?>
<div class="Body">
<div class="Main Container">
<?php get_template_part('public/partials/template/letters'); ?>
<div class="TpRwCont <?php echo $sidebar_position; ?>">
<main>
<section>
<div class="Top AAIco-movie_filter">
<h2 class="Title">
<?php if(isset($_GET['genre']) or isset($_GET['years'])){
echo 'Afisez ce doreste sufletul tau! :)';
} else {
echo get_search_query();
} ?>
</h2>
</div>
<ul class="MovieList Rows AX A04 B03 C20 D03 E20 Alt">
<?php if(isset($_GET['genre']) or isset($_GET['years'])){ ?>
<?php $args = array(
'post_type' => array('movies', 'series'),
'posts_per_page' => get_option( 'posts_per_page' ),
'post_status' => 'publish',
'no_found_rows' => true,
'ignore_sticky_posts' => true,
);
if( isset( $_GET['genre'] ) && $_GET['genre'] != '' ){
$args['tax_query'][] = array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => $_GET['genre']
);
}
if( isset( $_GET['years'] ) && $_GET['years'] != '' ){
$args['tax_query'][] = array(
'taxonomy' => 'annee',
'field' => 'term_id',
'terms' => $_GET['years']
);
}
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
get_template_part("public/partials/template/loop-principal");
endwhile;
endif; wp_reset_query(); ?>
<?php } else{
if(have_posts()) :
while(have_posts()) : the_post();
get_template_part("public/partials/template/loop-principal");
endwhile; ?>
<?php else: ?>
<div>
<?php _e('There are no articles', 'toroflix'); ?>
</div>
<?php endif;
} ?>
</ul>
</section>
</main>
<?php if($sidebar_position != 'NoSdbr'){ get_sidebar(); } ?>
</div>
</div>
</div>
<?php get_footer(); ?>
设置
'posts_per_page' => get_option( 'posts_per_page' ),
在 wordpress 中将显示 200 个结果。我希望对这些结果进行分页,假设每页 20 个帖子然后下一个,下一个.. 在页面内,没有其他结果页面的链接。
我尝试添加
<nav class="wp-pagenavi">
<?php echo TOROFLIX_Add_Theme_Support::toroflix_pagination(); ?>
</nav>
,我从“类别”页面获得的代码,其中分页可以正常工作,但不会在搜索结果中显示与分页相关的任何内容。 分类页面代码为:
<?php get_header();
$loop = new TOROFLIX_Movies();
$sidebar_position = $loop->sidebar_position('sidebar_type_category'); ?>
<div class="Body">
<div class="Main Container">
<?php $alphabet = get_option('alphabet_show');
if($alphabet){
get_template_part('public/partials/template/letters');
} ?>
<div class="TpRwCont <?php echo $sidebar_position; ?>">
<main>
<section>
<div class="Top AAIco-movie_filter">
<h2 class="Title"><?php single_cat_title(); ?></h2>
</div>
<ul class="MovieList Rows AX A04 B03 C20 D03 E20 Alt">
<?php if(have_posts()) :
while(have_posts()) : the_post();?>
<?php get_template_part("public/partials/template/loop-principal"); ?>
<?php endwhile; ?>
<?php else: ?>
<div>
<?php _e('There are no articles', 'toroflix'); ?>
</div>
<?php endif; ?>
</ul>
<nav class="wp-pagenavi">
<?php echo TOROFLIX_Add_Theme_Support::toroflix_pagination(); ?>
</nav>
</section>
</main>
<?php if($sidebar_position != 'NoSdbr'){ get_sidebar(); } ?>
</div>
</div>
</div>
<?php get_footer(); ?>
分类的导航效果很好,如何才能在搜索页面结果中获得相同的结果?
【问题讨论】:
-
请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。
标签: php wordpress navigation