WordPress在多个wp_query中创建自定义分页?

时间:2017-08-09 08:21:20

标签: php wordpress

我在front-page.php中有两个WP_QUERY,现在在这段代码中我想为它们添加一个分页。所以我只想问问一下,如果有可能的话呢?

CODE

$events = array(
    'post_type' => 'events',
    'post_status' => 'publish',
    'posts_per_page' => -1,
    'order' => 'asc'
);
$the_query = new WP_Query( $events );
$show_events = $the_query->get_posts();

$videos = array(
    'post_type' => 'videos',
    'post_status' => 'publish',
    'posts_per_page' => -1,
    'order' => 'asc'
);

$the_query = new WP_Query( $videos );
$show_videos = $the_query->get_posts();

$modEvent = count($show_events) / 3;

$eventPerRow = 3;
$eventVidPerRow = 2;

for( $i = 1; $i <= $modEvent; $i++ ) {
    $toStartEvent = ( $i == 1 ) ? 0 : ($i - 1) * $eventPerRow;
    $toStopEvent = ($i * $eventPerRow) -1;
    foreach( $show_events as $key => $event ) :
        //display events data
    endforeach;

    $toStartEventVid = ( $i == 1 ) ? 0 : ($i - 1) * $eventVidPerRow;
    $toStopEventVid = ($i * $eventVidPerRow) -1;
    foreach( $show_videos as $key => $videos ) :
        //display videos data
    endforeach;

    //PAGINATION HERE
}

0 个答案:

没有答案