WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using the custom meta box script from deluxeblogtips.com and I wondered if I could include get_posts within this array so that it displays all posts within a set post type ("Locations" for example)

        'name' => 'Location',    // File type: checkbox
        'id' => $prefix . location',
        'type' => 'checkbox',
        'desc' => 'Check this box to make any links open in a new browser window',
        'std' => 0                      // Value can be 0 or 1

Obviously I'd need to be able to select as many posts as I wanted. Any help would be greatly appreciated.

share|improve this question
up vote 1 down vote accepted

I'm assuming there is an option in the array that is meant to receive an array of options for the checkboxes...?

In which case, you can use get_posts to obtain an array of post objects (of which ever type), and then loop through this, to create an array of post titles:

For example..

$args=array('numberposts'=>-1,'post_type' => 'location');
$post_objs = get_posts($args);

foreach($post_objs as $post_obj):

You then have an array of location names, $options which you can feed into your metabox array.

Disclaimer: I've not tested this code.

share|improve this answer

Your Answer


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.