如何解决分页不适用于 WP_query 和不同的帖子类型
我正在修改现有的 wordpress 主题 Minimal Grid
我添加了自定义帖子类型,并且设法将默认帖子和自定义帖子加载到单独的页面上。但是,这样做后,该主题内置的分页似乎停止工作了。
我使用 WP_Query 来获取我需要的帖子类型。这是我的代码:
$argsprojects = array(
'post_type' => 'project_post','post_status' => 'publish','orderby' => 'date','order' => 'DESC',//'posts_per_page' => 6,//'paged' => ( get_query_var('page') ? get_query_var('page') : 1));
$loopprojects = new WP_Query( $argsprojects );
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<?PHP
if (have_posts()) :
$class = 'minimal-grid-posts-lists';
/*Check for masonry settings*/
$enable_masonry_post_archive = minimal_grid_get_option('enable_masonry_post_archive',true);
if ($enable_masonry_post_archive) {
$class = 'masonry-grid masonry-col';
}
/**/
echo '<div class="' . esc_attr($class) . '">';
/* Start the Loop */
while ( $loopprojects->have_posts() ) : $loopprojects->the_post();
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme,then include a file
* called content-___.PHP (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part('template-parts/content-project',get_post_format());
endwhile;
echo '</div>';
/**
* Hook - minimal_grid_posts_navigation.
*
* @hooked: minimal_grid_display_posts_navigation - 10
*/
do_action('minimal_grid_posts_navigation');
else :
get_template_part('template-parts/content','none');
endif; ?>
</main><!-- #main -->
</div><!-- #primary -->
<?PHP
$page_layout = minimal_grid_get_page_layout();
if ('no-sidebar' != $page_layout) {
get_sidebar();
}
?>
<?PHP
get_footer();
我希望这是足够的信息来帮助我。本站开发区如下: url dev website 非常感谢您的帮助!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。