2

WordPress のカスタム メタデータ プラグインを使用して、作業中のサイトにメタデータ グループを追加しています。

私がやりたいことは、次のように、必要に応じてさらにカスタム フィールドを追加できるカスタム フィールドを追加することです。カスタム フィールドの管理パネル ビュー

しかし、投稿を公開すると、次のように入力順序が乱れます。 データを入力すると、ランダムに並べ替えられます。

これが私のコードです。複数のフィールドは、x_add_metadata_field関数の下部に作成されていmultiple=> trueます。

function myfunction_x_init_cw_fields(){
  if( function_exists( 'x_add_metadata_field' ) && function_exists( 'x_add_metadata_group' ) ) {
$post_types = array( 'page' );
$args = array(
  'label' => 'Include Content Widgets', // Label for the group
  'context' => 'normal', // (post only)
  'priority' => 'default', // (post only)
  'autosave' => false //, // (post only) Should the group be saved in autosave? NOT IMPLEMENTED YET!
  //'exclude' => '', // posts#s to exclude
  //'include' => '', // posts#s to include
);
x_add_metadata_group( 'myfunction_cw_details', $post_types, $args );

x_add_metadata_field( 'myfunction_page_cw_field', $post_types, array(
  'group' => 'myfunction_cw_details', // the group name
  'description' => esc_html('Enter content widget slug under "content widgets"'),
  'label' => 'Content Widget Slugs',
  'multiple' => true
));
}
}

add_action( 'custom_metadata_manager_init_metadata', 'myfunction_x_init_cw_fields' );

基本的には、誰かが「ドキュメントに記載されていない結果を並べ替える設定がある」と言ってくれることを願っています。

4

1 に答える 1

0

これらを引数に追加しようとしましたか:

'orderby' => 'meta_value',
'order' => 'ASC' 

例えば

x_add_metadata_field( 'myfunction_page_cw_field', $post_types, array(
  'group' => 'myfunction_cw_details', // the group name
  'description' => esc_html('Enter content widget slug under "content widgets"'),
  'label' => 'Content Widget Slugs',
  'multiple' => true,
  'orderby' => 'meta_value',
  'order' => 'ASC' 
));
于 2014-01-08T11:11:19.267 に答える