📜  wordpress 仅查询粘性帖子 - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:32.949000             🧑  作者: Mango

代码示例1
// get sticky posts from DB
$sticky = get_option('sticky_posts');
// check if there are any
if (!empty($sticky)) {
    // optional: sort the newest IDs first
    rsort($sticky);
    // override the query
    $args = array(
        'post__in' => $sticky
    );
    query_posts($args);
    // the loop
    while (have_posts()) {
         the_post();
         // your code
    }
}