Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How to make in the admin's dashboard a <select> with the list of all posts of specified post type?

I need this in order to save a post ID with set_option() call.

How to do this?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Use wp_dropdown_pages() to create the drop down. It accepts an post_type parameter.

To avoid collisions with plugins filtering this function you may use walk_page_dropdown_tree() and build your own select. See this post for a code example.

share|improve this answer
    
It does not work because get_posts(array('post_type'=>'department')) returns nothing (despite of the fact that a post of the type 'department' exists. –  porton Apr 10 '12 at 20:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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