【发布时间】:2014-09-30 21:38:04
【问题描述】:
我目前正在通过查询从数据库中获取所有帖子。包含的 php 代码是自定义 Wordpress 模板的一部分。我正在使用来自以下位置的自定义元框:https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress
我需要做什么才能每 6 个帖子分页一次?
<?php
//get_template_part( 'content', 'page' );
echo'<h2 class="section-header-dark">'.get_the_title().'</h2><hr>';
//adjusting the query
$args = array(
'post_type' => 'blog',
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => ASC
);
// The Query
$latest_post = new WP_Query( $args );
// The Loop
if ( $latest_post->have_posts() )
{
while ( $latest_post->have_posts() )
{
$latest_post->the_post();
$desc = wpautop( get_post_meta( get_the_ID(), '_cw_desc', true ) );
echo'<div class=""><h5 class="">'. get_the_title(). '</h5>';
echo $desc;
echo'<h6 class="news_date f_right"><i>'. get_the_date(). '</i></h6>';
echo'</div><hr>';
}
}
else
{
// no posts do nothing
}
wp_reset_postdata();
?>
【问题讨论】:
标签: php wordpress pagination