I’m working on carousel slider plugin. So far so good! But i want the user to be able to select which post type the slider must slide.

WordPress does have a function called: get_post_types( $args, $output, $operator);

But this function has an argument called ‘_builtin’ (bool). True returns all standard wordpress post_types like ‘post, ‘page’ and ‘attachement’. False returns all custom post types.

What I want is to return both.

    public function post_type() {
        $args = array( 
            'public'    => true,
            '_builtin'  => true or false // I want this to return both true and false
        );

        $get_post_types = get_post_types( $args, 'names', $output);

        return $get_post_types;
        //var_dump($get_post_types);
    }

Actual Question

Is there some kind of workaround so i can select both true and false or is it recommended to write my own custom wpdb query? Or is there some kind of method to select true and false?

p.s. i use this function in a class so that explains the “public” keyword

1 Answer
1

Thanks to @mmm

The solution in this case is pretty simple.
Just pass an empty $args array. Then it neglects the default ‘_builtin’

Example

$get_post_types = get_post_types( $args = array(), $output, $operator );
return $get_post_types;

Leave a Reply

Your email address will not be published. Required fields are marked *