标签:includes func 列表 key post include 路径 参数 com
在链接上添加"?orderby=ID"即可。
注意不能用小写的id,因为wp-includes/class-wp-query.php中的parse_orderby方法限定了key值:
// Used to filter values.
$allowed_keys = array(
‘post_name‘, ‘post_author‘, ‘post_date‘, ‘post_title‘, ‘post_modified‘,
‘post_parent‘, ‘post_type‘, ‘name‘, ‘author‘, ‘date‘, ‘title‘, ‘modified‘,
‘parent‘, ‘type‘, ‘ID‘, ‘menu_order‘, ‘comment_count‘, ‘rand‘,
);
取值不合法或没有传递orderby参数都会按post_date排序。
wordpress会按以下路径传递该参数:
1. wp-admin/includes/post.php的wp_edit_posts_query( $q = false )首次获取参数;
2. wp-includes/functions.php的wp();
3. wp-includes/class-wp.php的main();
4. wp-includes/class-wp.php的query_posts();
5. wp-includes/class-wp-query.php的query();
6. wp-includes/class-wp-query.php的get_posts(),对orderby的处理在2148-2202行。
标签:includes func 列表 key post include 路径 参数 com
原文地址:https://www.cnblogs.com/imsi/p/9683736.html