0

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)

array(
        '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.

1 Answer 1

1

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);
$options=array();

foreach($post_objs as $post_obj):
     $options[]=$post_obj->post_title;
endforeach;

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

Disclaimer: I've not tested this code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.