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

I’m using Redux and I want select one post/page form select list. But I want choose form some post types (or all).
This is my Redux code for this field.

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

Related posts

1 comment

  1. There are two things that you have to change in your code so that it works properly. Here’s a working version:

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

    The difference here is that we have 'data' => 'posts'(instead of pages) and we also added 'numberposts' => -1 to the args array.

    When you use 'data' => 'pages', the function [get_pages()][1] is used, which only supports hierarchical post types.

Comments are closed.