Is there a function to list all custom post types in a metabox?

I have

wp_list_pages( $args );

to list the pages in metabox but now I need also to list all custom post types.

Thanks for advices


   $args = array(
  'public'   => true,
    '_builtin' => false

 $output = 'names'; // names or objects, note names is the default
  $operator = 'and'; // 'and' or 'or'

 $post_types = get_post_types( $args, $output, $operator ); 

 foreach ( $post_types  as $post_type ) {

     echo '<p>' . $post_type . '</p>';


It will list of all public custom post types and you can read documentation on get_post_types here .

  • 1
    Would be nice if you can link to the get_post_types (which is used here) codex page and briefly explain how the code works :-) – Pieter Goosen Sep 15 '14 at 7:30
  • Glad it worked for you ! Enjoy coding :) – Rohil_PHPBeginner Sep 15 '14 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.