WordPress:为置顶帖提供特定的固定顺序

发布于 2024-09-03 13:17:52 字数 95 浏览 2 评论 0原文

有没有办法给置顶帖一个特定的顺序,而不是总是显示在列表的顶部?例如,我希望一个置顶帖子始终显示为第 5 个帖子,另一个置顶帖子始终显示为第 8 个帖子。

谢谢!

Is there a way to give a sticky post a specific order, rather than always displaying at the top of the list? For example, I want one sticky post to always display as the 5th post, and another to always display as the 8th.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凡间太子 2024-09-10 13:17:52
//------------ Add page ordering for posts ----------------//

function dark_post_prepare( $query ) {
    $query->set( 'orderby', array('menu_order' => 'ASC', 'ID'=>'DESC') );
}
add_action( 'pre_get_posts', 'dark_post_prepare', 1 );

//---------------- Register: Page-atributes to post (Add order of post)
add_action( 'admin_init', 'dark_posts_order' );
function dark_posts_order() {
    add_post_type_support( 'post', 'page-attributes' );
}
//------------ Add page ordering for posts ----------------//

function dark_post_prepare( $query ) {
    $query->set( 'orderby', array('menu_order' => 'ASC', 'ID'=>'DESC') );
}
add_action( 'pre_get_posts', 'dark_post_prepare', 1 );

//---------------- Register: Page-atributes to post (Add order of post)
add_action( 'admin_init', 'dark_posts_order' );
function dark_posts_order() {
    add_post_type_support( 'post', 'page-attributes' );
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文