Custom Fields
Re-Envisioned
Support General Multiple Post Types for field type: select_advanced

  • Creator
    Topic
  • #20430
    Resolved Michael Soriano
    Participant

    I want to allow multiple post types to select_advanced field. I have a post type named “plot”, but I also want to add another post type in the autosuggest.

    See commented below.

    array(
                        'name'        => esc_html__( 'Plot', self::$namespace ),
                        'id'          => self::$pin . '_plot_id',
                        'type'        => 'post',
                        'label_description' => esc_html__( 'Start typing', self::$namespace ),
                        'post_type'   => 'plot',  <-----I WANT TO ALLOW MULTIPLE POST TYPES HERE---->
                        'field_type'  => 'select_advanced',                   
                        'query_args'  => array(
                            'post_status'    => 'publish',
                            'posts_per_page' => -1,
                        )
                    )

    I couldn’t find it in the docs. Is this possible?

    Or can I achieve this using another field type?

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #20433
    Long Nguyen
    Moderator

    Hi,

    To show multiple post types, you can use an array of post types.

    'post_type' => array( 'post', 'page', 'plot' )

    We’ve written about this setting in the documentation

    post_type Post type. Can be string (for single post type) or array (for multiple post types). Required.

    You can also select multiple post types with MB Builder, see my screenshot https://share.getcloudapp.com/DOuAoPqY.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.