我创建了一个帖子类型“事件”,它使用自定义字段“基准”(瑞典语表示日期)。我希望此帖子类型的默认视图按此字段排序。
到目前为止,我得到了:
register_post_type(
'events',
array(
'labels' => array(
'name' => __( 'Arrangemang' ),
'singular_name' => __( 'Arrangemang' )
),
'supports' => array(
'title',
'editor',
'custom-fields'
),
'public' => true,
'has_archive' => true,
'query_var' => array(
'post_type' => 'events',
'meta_key' => 'Datum',
'orderby' => 'meta_value',
'order' => 'ASC',
),
)
);
但是排序不起作用。如果我在事件的存档页面上运行,print_r($wp_query->query_vars);
我会得到:
Array
(
[post_type] => events
[error] =>
[m] => 0
[p] => 0
[post_parent] =>
[subpost] =>
[subpost_id] =>
[attachment] =>
[attachment_id] => 0
[name] =>
[static] =>
[pagename] =>
[page_id] => 0
[second] =>
[minute] =>
[hour] =>
[day] => 0
[monthnum] => 0
[year] => 0
[w] => 0
[category_name] =>
[tag] =>
[cat] =>
[tag_id] =>
[author_name] =>
[feed] =>
[tb] =>
[paged] => 0
[comments_popup] =>
[meta_key] =>
[meta_value] =>
[preview] =>
[s] =>
[sentence] =>
[fields] =>
[category__in] => Array
(
)
[category__not_in] => Array
(
)
[category__and] => Array
(
)
[post__in] => Array
(
)
[post__not_in] => Array
(
)
[tag__in] => Array
(
)
[tag__not_in] => Array
(
)
[tag__and] => Array
(
)
[tag_slug__in] => Array
(
)
[tag_slug__and] => Array
(
)
[meta_query] => Array
(
)
[ignore_sticky_posts] =>
[suppress_filters] =>
[cache_results] => 1
[update_post_term_cache] => 1
[update_post_meta_cache] => 1
[posts_per_page] => 100
[nopaging] =>
[comments_per_page] => 50
[no_found_rows] =>
[order] => DESC
[orderby] => wp_posts.post_date DESC
)
我是否误解了 的论点query_var
,register_post_type
或者为什么没有按照我的要求对列表进行排序?