我已经为一个页面创建了一个php模板,并显示来自我的自定义帖子类型的帖子,但我正在根据以下条件跳过帖子。
这是我的页面模板代码。
$paged = ( get_query_var(\'page\') ) ? get_query_var(\'page\') : 1;
$args = array(
\'post_type\' => \'custom-post-type\',
\'paged\' => $paged,
\'order_by\' => \'DESC\',
\'posts_per_page\' => 10, //my posts count, but on page post count mismatch
\'meta_value\' => \'someMetaVale\',
);
$query= WP_query($args);
while ( $query->have_posts() ) {
$query->the_post();
$meta_value = get_post_meta(get_the_ID,\'some_meta_key\',true);
$post_args = array(
\'post_type\' => \'post\',
\'posts_per_page\' => 1,
\'meta_value\' => $meta_value,
);
$result = get_posts($post_args);
if(!empty($result[0]->ID)) // here is my condition where i am skipping posts.
{
the_title(); //here i am printing post title
}
}
<div class="dt-pagination-nav">
<?php if ($query->max_num_pages > 1)
{ // check if the max number of pages is greater than 1
?>
<?php
$big = 999999999; // need an unlikely integer
echo paginate_links( array(\'base\' => str_replace( $big, \'%#%\', esc_url( get_pagenum_link( $big ) ) ),
\'format\' => \'page/%#%\',
\'current\' => max( 1, get_query_var(\'page\') ),
\'total\' => $query->max_num_pages,
\'add_fragment\' => \'\',
));
?>
<?php } ?>
</div>`
出现的问题是,我在页面中的帖子不匹配,因为我正在跳过帖子,所以请建议一个解决方案,我也可以跳过帖子,并使我的计数正确