Example #1
0
function cmb2_add_page_mb()
{
    $prefix = '_ab_';
    $cmb = new_cmb2_box(array('id' => $prefix . 'pagemb', 'title' => __('Sample Metabox', 'ab'), 'object_types' => array('page'), 'show_on' => array('key' => 'page-template', 'value' => 'about.php'), 'context' => 'normal', 'priority' => 'default'));
    $cmb->add_field(array('name' => __('Some Info', 'ab'), 'id' => $prefix . 'someinfo', 'type' => 'text', 'default' => 'hello'));
    $cmb->add_field(array('name' => __('Another Info', 'ab'), 'id' => $prefix . 'another_info', 'type' => 'text'));
    $cmb->add_field(array('name' => __('Gallery', 'ab'), 'id' => $prefix . 'gallery', 'type' => 'file_list'));
    $cmb->add_field(array('name' => __('A Dropdown', 'ab'), 'id' => $prefix . 'dropdown', 'type' => 'pw_multiselect', 'options' => all_posts()));
}
Example #2
0
<?php

//this script will display all the current posts in the database
$posts = all_posts();
//shut up warnings
error_reporting(0);
include "includes/header.inc";
?>
<div id="content">
  <ul id="subnav">
    <li><a href="post_new.php">New Post</a></li>
  </ul>
  <?php 
//build a table of all the posts
postsTable($posts);
?>
</div>
<?php 
include "includes/footer.inc";
?>

<?php 
//this function finds all the posts in the database
function all_posts()
{
    include "includes/db_con.inc";
    $conn = conDB();
    $query = "SELECT * FROM posts";
    $posts = q($query);
    return $posts;
}