Làm cách nào để tìm nạp meta bài đăng trong WordPress?

WP_Query là bạn của bạn. Nó cho phép bạn lấy nội dung từ cơ sở dữ liệu theo yêu cầu của bạn. Trong bài viết này, tôi sẽ giải thích từ trên xuống dưới về cách thức hoạt động của WP_Query. Bắt đầu nào

Vòng lặp tùy chỉnh

Chìa khóa để hoạt động tốt với các truy vấn tùy chỉnh là nắm vững các đối số mà bạn có thể chuyển cho chúng. Vòng lặp trên một trang lưu trữ thông thường sẽ giống như thế này

<?php if ( have_posts() ) : ?>
	<?php while( have_posts() ) : the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>

Khi trang được tải, WordPress đã lấy đúng bài viết. Đối với các truy vấn tùy chỉnh, chúng tôi sẽ cần một vòng lặp tùy chỉnh. Mã này rất giống nhau, ở đây đi

<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>

Đối với truy vấn WordPress mới, chúng tôi sử dụng lớp

<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
1. Nó yêu cầu một số tham số để chỉ định loại bài đăng chúng tôi cần. Sau đó, chúng tôi gọi các phương thức
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
2 và
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
3 trên đối tượng
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
4 của chúng tôi

Đối số đơn giản

Một số tham số hoàn toàn đơn giản, ví dụ: thẻ hoặc tag_id. Cái trước lấy một con sên thẻ, cái sau lấy id thẻ. Tương tự như vậy, bạn có thể phân tách nhiều mục bằng dấu phẩy hoặc sử dụng id phủ định để cho biết rằng bạn cần tìm nạp các bài đăng không có gắn thẻ cụ thể đó

$args = array( 
	'post_type'   => 'post',
	'tag_id'      => '22,92,44,-21'
);
$our_posts = new WP_Query( $args );

Đoạn mã sẽ truy xuất các bài đăng có bất kỳ thẻ nào trong số ba thẻ đầu tiên được đính kèm với chúng, nhưng không phải thẻ thứ 4.  

<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
5, author_name,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
6,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
7,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
8(đối với cụm từ tìm kiếm),
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
9,
$args = array( 
	'post_type'   => 'post',
	'tag_id'      => '22,92,44,-21'
);
$our_posts = new WP_Query( $args );
0 là ví dụ về một số trường đơn giản hơn. Một số trường, chẳng hạn như
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
9, cần bạn chuyển một mảng trạng thái nếu bạn muốn sử dụng nhiều giá trị

<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
4

Truy vấn phân loại

Đối với những điều dễ dàng, sử dụng các đối số được mô tả để truy xuất nội dung tùy thuộc vào danh mục hoặc thẻ là đủ, nhưng nếu bạn có phân loại tùy chỉnh hoặc bạn cần kết hợp nhiều tham số thì sao?

<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
5

Ở đây, đoạn mã trên lấy một số bài đăng từ loại bài đăng 'sách' của chúng tôi, bao gồm một số tham số phân loại bằng cách sử dụng hai mảng được xác định trong

$args = array( 
	'post_type'   => 'post',
	'tag_id'      => '22,92,44,-21'
);
$our_posts = new WP_Query( $args );
2. Trong truy vấn, chúng tôi đã chỉ định rằng để tìm nạp sách do tác giả viết năm 73, 65 hoặc 197, không thuộc thể loại khoa học viễn tưởng hoặc kinh dị. Tham số quan hệ mô tả mối quan hệ giữa hai mảng. Trong trường hợp của chúng tôi, đó là mối quan hệ '_______63', có nghĩa là cả hai trường hợp phải đúng

Nếu chúng tôi đã sử dụng

$args = array( 
	'post_type'   => 'post',
	'tag_id'      => '22,92,44,-21'
);
$our_posts = new WP_Query( $args );
4, thì nó sẽ truy xuất những cuốn sách không thuộc thể loại khoa học viễn tưởng hoặc kinh dị. Hoặc chúng được viết bởi ba tác giả được chỉ định

Truy vấn meta

Truy vấn meta rất giống với truy vấn phân loại trong cấu trúc, nhưng chúng sử dụng dữ liệu từ bảng meta bài đăng để lọc bài đăng. Đoạn mã bên dưới sẽ tìm nạp tất cả các bài đăng đã xuất bản có hình ảnh nổi bật

<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
9

WordPress lưu trữ

$args = array( 
	'post_type'   => 'post',
	'tag_id'      => '22,92,44,-21'
);
$our_posts = new WP_Query( $args );
5 của hình ảnh nổi bật cho một bài đăng bằng cách sử dụng trường
$args = array( 
	'post_type'   => 'post',
	'tag_id'      => '22,92,44,-21'
);
$our_posts = new WP_Query( $args );
6. Vì vậy, trong đoạn mã trên, chúng tôi truy xuất tất cả các bài đăng có giá trị meta
$args = array( 
	'post_type'   => 'post',
	'tag_id'      => '22,92,44,-21'
);
$our_posts = new WP_Query( $args );
6 không trống

Trong đoạn mã trên, chúng ta có thể biết rằng để so sánh thuộc tính và loại, chúng ta có thể sử dụng vô số giá trị quen thuộc từ SQL, chẳng hạn như

$args = array( 
	'post_type'   => 'post',
	'tag_id'      => '22,92,44,-21'
);
$our_posts = new WP_Query( $args );
8,
$args = array( 
	'post_type'   => 'post',
	'tag_id'      => '22,92,44,-21'
);
$our_posts = new WP_Query( $args );
9,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
40,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
41,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
42,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
43,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
44,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
45,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
46, . 5 trở lên) và
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
51 (từ WordPress 3. 5 trở lên). Để so sánh số hoặc ngày, chúng tôi sử dụng thuộc tính loại. Và các giá trị có thể có của thuộc tính loại là
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
52,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
53,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
54,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
55,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
56,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
57,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
58,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
59,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
90. Tương tự như truy vấn phân loại. Chúng ta có thể xếp chồng nhiều thông số kỹ thuật và sau đó sử dụng các tham số quan hệ để chỉ định mối quan hệ giữa chúng

Tương tự như các truy vấn phân loại, chúng ta có thể xếp chồng nhiều thông số kỹ thuật và sau đó sử dụng các tham số quan hệ để chỉ định mối quan hệ giữa chúng

<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
6

Thông số ngày

Ngày có thể hơi phức tạp nhưng rất linh hoạt. Có rất nhiều hình ảnh minh họa nếu bạn cần thêm chi tiết

Chúng ta có thể sử dụng năm, số tháng, w (tuần trong năm), ngày và một vài tham số khác để truy xuất các bài đăng trong một thời điểm

ví dụ 1. Truy xuất tất cả các bài đăng từ tháng 3 năm 2013

<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
7

ví dụ 2. Truy xuất các bài đăng được viết từ 9 giờ sáng đến 5 giờ chiều vào các ngày trong tuần

<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
8

Kết quả đặt hàng

Đối với kết quả đặt hàng, WordPress cung cấp cho chúng tôi

<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
91 và thông số đặt hàng. Và tham số thứ tự rất đơn giản. Bạn có thể sử dụng
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
92 hoặc
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
93 để sắp xếp thứ tự tăng dần hoặc giảm dần

Các giá trị có thể có cho tham số _______70 cab là.

<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
95,
$args = array( 
	'post_type'   => 'post',
	'tag_id'      => '22,92,44,-21'
);
$our_posts = new WP_Query( $args );
5,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
5,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
98,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
99,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
60,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
61,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
62,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
63,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
64,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
65,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
66,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
67,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
68,
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
69

Đặt hàng bởi

<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
67 có thể đặc biệt hữu ích. Trong trường hợp này, cũng cần chỉ định trường
<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$result = new WP_Query( $args );
if ( $result->have_posts() ) : 
?>
	<?php while( $result->have_posts() ) : $result->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
71

Bài meta ở đâu trong WordPress?

Meta bài đăng trong tính năng WordPress được ẩn trên tùy chọn màn hình của bảng điều khiển WordPress của bạn theo mặc định . Để hiển thị tính năng này trong bài đăng hoặc trang blog của bạn, trước tiên bạn cần truy cập khu vực quản trị WordPress của mình. Nếu bạn thêm tính năng này vào tất cả các bài đăng của mình thì bạn phải vào Bài đăng → Tất cả bài đăng.

Bài meta trong WordPress là gì?

Dữ liệu meta của bài đăng là thông tin "quản trị" mà bạn cung cấp cho người xem về mỗi bài đăng . Thông tin này thường bao gồm tác giả của bài đăng, khi nó được viết (hoặc đăng) và cách tác giả phân loại bài đăng cụ thể đó.

Nhận bài meta là gì?

Nếu giá trị của tham số $key là sai, get_post_meta sẽ trả về toàn bộ mảng meta của bài đăng, ngay cả khi $single được đặt thành true . Ví dụ. Sao chép. get_post_meta( $post_id, FALSE, TRUE); .