Redux框架,Wordpress,从所有帖子类型中选择页面/帖子


Redux framework, Wordpress, Select page/post from all post types

我正在使用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),
            ),
       ),

为了使代码正常工作,您必须更改两件事。这是一个工作版本:

'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],它只支持分层的帖子类型。