Skip to content

Instantly share code, notes, and snippets.

@norcross
Created September 11, 2012 14:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norcross/3698796 to your computer and use it in GitHub Desktop.
Save norcross/3698796 to your computer and use it in GitHub Desktop.
Get pages inside CMB class
case 'page_select':
echo '<select name="', $field['id'], '" id="', $field['id'], '">';
$linked_items = get_posts(array(
'post_type' => array ('page',),
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'modified',
'order' => 'DESC'
));
foreach ($linked_items as $linked_item) {
echo '<option value="', $linked_item->ID, '"', $meta == $linked_item->ID ? ' selected="selected"' : '', '>', $linked_item->post_title, '</option>';
}
echo '</select>';
echo '<p class="cmb_metabox_description">', $field['desc'], '</p>';
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment