【问题标题】:WordPress Custom Metadata Plugin reorders fieldsWordPress 自定义元数据插件重新排序字段
【发布时间】:2013-11-08 23:15:10
【问题描述】:

我正在使用 WordPress'Custom Metadata Plugin 将元数据组添加到我正在开发的网站。

我想做的是添加一个自定义字段,可以根据需要添加更多自定义字段,例如:

但是当我发布帖子时,它会打乱输入顺序,如下所示:

这是我的代码。多个字段在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' );

基本上,我希望有人会说“嘿,文档中没有提到的结果排序设置。”

【问题讨论】:

    标签: php wordpress plugins metadata field


    【解决方案1】:

    您是否尝试将这些添加到您的参数中:

    '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' 
    ));
    

    【讨论】:

      猜你喜欢
      • 2017-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-14
      • 1970-01-01
      • 1970-01-01
      • 2015-08-11
      相关资源
      最近更新 更多