rilwis/meta-box — Issue #88: Option to select pages?
Author: infectedfx
Created: 2012-02-26 00:43:43+00:00
State: open

Hello, i try to get an option with select or checkbox list with published pages, but i don't know how make them... i try use a new class, but i can't make to work, do you can help me?

thank you very much for your time.

```php
// show pages list
function show_field_pages($field, $meta) {
global $post;

if (!is_array($meta)) $meta = (array) $meta;

$this->show_field_begin($field, $meta);

$options = $field['options'];
$pages = get_pages($options['args']);

// checkbox_list
if ('checkbox_list' == $options['type']) {
foreach ($pages as $page) {
echo "ID, $meta), true, false) . " /> $page->name
";
}
}
// select
else {
echo "";

foreach ($pages as $page) {
echo "
ID, $meta), true, false) . ">$page->post_title
";
}
echo "";
}

$this->show_field_end($field, $meta);
}

// show posts list
function show_field_posts($field, $meta) {
global $post;

if (!is_array($meta)) $meta = (array) $meta;

$this->show_field_begin($field, $meta);

$options = $field['options'];
$posts = get_posts($options['args']);

// checkbox_list
if ('checkbox_list' == $options['type']) {
foreach ($posts as $post) {
echo "ID, $meta), true, false) . " /> $post->name
";
}
}
// select
else {
echo "";

foreach ($posts as $post) {
echo "
ID, $meta), true, false) . ">$post->post_title
";
}
echo "";
}

$this->show_field_end($field, $meta);
}
```