更新时间:2023-12-01 23:16:04
下面的函数将即时贴推到顶部,你应该可以使用它来帮助你的情况.
The below function pushes stickies to the top, you should be able to use this to help in your case.
add_filter('the_posts', 'bump_sticky_posts_to_top');
function bump_sticky_posts_to_top($posts) {
$stickies = array();
foreach($posts as $i => $post) {
if(is_sticky($post->ID)) {
$stickies[] = $post;
unset($posts[$i]);
}
}
return array_merge($stickies, $posts);
}