使用搜索过滤器插件。我使用获取数据库中存在的帖子总数
$wp_query->found_posts
但是,当用户过滤页面上的结果时,该数字会根据过滤器上显示的帖子数量而变化。我怎样才能得到不管用户过滤什么都不会改变的静态帖子总数?
更新:这是我的完整模板代码。我尝试了下面的答案,但无法使用我的模板。有什么想法吗?
if ( $query->have_posts() )
{
?>
<ul id="florefs">
<?php
while ($query->have_posts())
{
$query->the_post();
?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><i class="x-icon florex x-icon-angle-right" data-x-icon="" aria-hidden="true"></i> <?php the_field(\'br_name\'); ?></a>
<div id="flosex"><span class="fimi"><?php the_field(\'br_category\'); ?></span><span class="flag <?php echo strtolower(get_field(\'br_heritage\')); ?>"></span><span class="fama"><?php the_field(\'br_heritage\'); ?></span></div></li>
<?php
}
?>
</ul>
<div class="filhead">Page <?php echo $query->query[\'paged\']; ?> of <?php echo $query->max_num_pages; ?></div>
<div class="pagination">
<div class="nav-next"><?php previous_posts_link( \'<i class="x-icon x-icon-arrow-left" data-x-icon="" aria-hidden="true"></i> Previous page\' ); ?></div>
<div class="nav-previous"><?php next_posts_link( \'Next page <i class="x-icon x-icon-arrow-right" data-x-icon="" aria-hidden="true"></i>\', $query->max_num_pages ); ?></div>
<?php
/* example code for using the wp_pagenavi plugin */
if (function_exists(\'wp_pagenavi\'))
{
echo "<br />";
wp_pagenavi( array( \'query\' => $query ) );
}
?>
</div>
<div id="prasti"><span class="prase">PROBLEM HERE</span><span class="praso"><?php echo $query->found_posts; ?></span><span class="prasif">NEEDS</span><span class="prasi">CHANGE</span></div>
<?php
}
else
{
echo "There are no results for your selected criteria.";
}
?>