カスタムフィールド「Datum」(スウェーデン語で日付)を使用する投稿タイプ「events」を作成しました。この投稿タイプのデフォルト ビューをこのフィールドでソートしたい。
これまでのところ、私は得ました:
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
うか、それとも私が要求したとおりにリストがソートされないのはなぜですか?