Home>Article>CMS Tutorial> How to get the list of pinned articles in WordPress
#How to get the list of pinned articles in wordpress?
In WordPress, maybe you want to call the set specified article list. How to implement this function? The implementation method is introduced below, please refer to it
Recommended: "WordPress Tutorial"
First of all, you need to understand the query_posts function. The function of this function is to retrieve, select, and sort articles, and use the selected and sorted articles in the subsequent LOOP loop. For example:
The code is as follows
';the_title();echo ''; endwhile; wp_reset_query();
will randomly list the title of an article. As for the specific parameters of query_posts, please refer to the development manual.
Next, we need to select the top article list by adjusting the parameters of query_posts.
The code is as follows:
$query_post = array( 'posts_per_page' => 10, 'post__in' => get_option('sticky_posts'), 'caller_get_posts' => 1 ); query_posts($query_post); ?>
The parameters are placed in $query_post in the form of an array. The key parameters are 'post__in' =>get_option('sticky_posts') and 'caller_get_posts' => ; 0.
'post__in' => get_option('sticky_posts') determines that the LOOP calls the list of sticky articles. The function of 'caller_get_posts' is to exclude non-specified articles, that is, no other articles will be displayed except the top articles. (Without adding, if the pinned article entry is less than the value specified by 'posts_per_page', the latest article will be used to replace it.)
The above is the detailed content of How to get the list of pinned articles in WordPress. For more information, please follow other related articles on the PHP Chinese website!