Ví dụ: hiển thị 4 bài viết mới nhất trong đó: 1 bài viết mới nhất cấp 1 và 3 tin bài mới nhất cấp 2. Vậy code dùng như sau:
// Code hiển 1 bài viết mới nhất
<?php
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 1,
'offset' => 0,
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'is_hot',
'value' => '1',)));
$the_query = new WP_Query($args);
while ($the_query->have_posts()) {
$the_query->the_post();
?>
// code của bạn
<?php } ?>
// Code hiển 3 bài viết mới nhất bỏ qua bài đầu tiên
<?php
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 3,
'offset' => 1,
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'is_hot',
'value' => '1',)));
$the_query = new WP_Query($args);
while ($the_query->have_posts()) {
$the_query->the_post();
?>
// code của bạn
<?php } ?>
<?php
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 3,
'offset' => 1,
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'is_hot',
'value' => '1',)));
$the_query = new WP_Query($args);
while ($the_query->have_posts()) {
$the_query->the_post();
?>
// code của bạn
<?php } ?>
Đăng nhận xét
Vui lòng không spam comment bạn nhé!