1

我正在使用 Redux,我想选择一个帖子/页面表单选择列表。但我想选择一些帖子类型(或全部)。这是我在这个领域的 Redux 代码。

        'fields'     => array(
            array(
                'id'       => 'featured_post_type',
                'type'     => 'select',
                'multi'    => false,
                'data'      => 'pages',
                'args' => array('post_type' => array('nyheter_grenene', 'nyheter_forbundet', 'stup') ),
                'title'    => __('Featured Post', TD),
                'subtitle' => __('Selected post will be displayed in page top menu', TD),
                //'desc'     => __('Page will be marked as front for this post type', TD),
            ),
       ),
4

1 回答 1

2

您必须在代码中更改两件事才能使其正常工作。这是一个工作版本:

'fields'     => array(
    array(
        'id'       => 'featured_post_type',
        'type'     => 'select',
        'multi'    => false,
        'data'     => 'posts',
        'args'     => array( 'post_type' =>  array( 'nyheter_grenene', 'nyheter_forbundet', 'stup' ), 'numberposts' => -1 ),
        'title'    => __( 'Featured Post', TD ),
        'subtitle' => __( 'Selected post will be displayed in page top menu', TD ),
        //'desc'     => __( 'Page will be marked as front for this post type', TD ),
    ),
),

这里的区别在于我们有'data' => 'posts'(而不是pages)并且我们还添加'numberposts' => -1到了args数组中。

使用时,使用'data' => 'pages'该功能,该功能[get_pages()][1]仅支持分层帖子类型。

于 2015-11-12T12:59:49.567 回答