我只对一个类别“procesos”进行了分页,这就是代码:
<?php if(has_term('procesos', 'dslc_projects_cats')): ?>
<?php
$args = array(
'posts_per_page' => 7,
'post_type' => 'dslc_projects',
'tax_query' => array('dslc_projects_cats', 'field' => 'id', 'terms' => 'procesos')
);
$processes = get_posts($args);
$ids = array();
foreach ($processes as $process) {
$ids[] += $process->ID;
}
$thisindex = array_search($post->ID, $ids);
//var_dump($ids);
$previd = $ids[$thisindex-1];
$nextid = $ids[$thisindex+1];
?>
<div class="row">
<div class="container inner-pagination">
<div class="col-xs-6">
<?php
if(!empty($previd))
echo '<a rel="prev" href="'.get_permalink($previd).'"> « '.get_the_title($previd).'</a>';
?>
</div>
<div class="col-xs-6 text-right">
<?php
if(!empty($nextid))
echo '<a rel="next" href="'.get_permalink($nextid).'">'.get_the_title($nextid).' » </a>';
?>
</div>
</div>
</div>
<?php endif; ?>
分页仅出现在带有“procesos”类别的帖子中,我将代码修改为:
<?php
$args = array(
'posts_per_page' => 13,
'post_type' => 'dslc_projects',
);
$processes = get_posts($args);
$ids = array();
foreach ($processes as $process) {
$ids[] += $process->ID;
}
$thisindex = array_search($post->ID, $ids);
//var_dump($ids);
$previd = $ids[$thisindex-1];
$nextid = $ids[$thisindex+1];
?>
其余的是相同的,现在我在所有帖子中都有分页并继续(没有分类):http://globalarmor.com.mx/project-view/desmontaje/
我希望按类别分页,就像之前一样,但是在所有类别中(有四个)。我怎样才能做到这一点?