In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to add sorting options for WordPress articles, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The default WordPress has a sorting options panel only on the page, and you can use the following code to make articles have sorting options panel as well.
Just add the code to the current theme function template functions.php.
Add_action ('admin_init',' posts_order'); function posts_order () {add_post_type_support ('post',' page-attributes');}
If the frontend wants to sort articles, you need to add parameters to the main loop:
$order_posts = new WP_Query ('post_type' = >' post', 'post_status' = >' publish', 'orderby' = >' menu_order', 'order' = >' ASC',))
The background article list displays the sort number:
Add_action ('manage_posts_custom_column',' zm_posts_order_show_columns'); function zm_posts_order_show_columns ($name) {global $post;switch ($name) {case 'order':$views = $post- > menu_order;echo $views;break;}} add_filter (' manage_posts_columns', 'zm_posts_order_columns'); function zm_posts_order_columns ($defaults) {$defaults [' order'] = 'sort'; return $defaults;}
Batch zeroing sort number:
Global $wpdb;$wpdb- > query ("UPDATE wp_posts SET menu_order = 0 WHERE post_type = 'post'"); this is all the content of the article "how to add sorting options to WordPress articles". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.