Thứ Sáu, 24 tháng 2, 2017

Hiển thị các bài viết được Sticky trong Wordpress

<?php
$sticky = get_option( 'sticky_posts' );
rsort( $sticky );
$sticky = array_slice( $sticky, 0, 2 );
if (is_numeric($sticky[0])) {
query_posts( array( 'post__in' => $sticky, 'ignore_sticky_posts' => 2 ) );
while ( have_posts() ) : the_post(); ?>

// Gọi hàm hiển thị nội dung

<?php endwhile;
wp_reset_query(); } ?>

Không có nhận xét nào:

Đăng nhận xét