Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm currently designing a musician's wordpress theme, and am looking to create a user-controlled dynamic gig list. It doesn't have to have a link to any event pages, just a simple "where, when, with who" kind of thing. I've done this before using PHP, but am wondering what the best way to do it IN WORDPRESS would be.

I've tested a method using custom post types, but I feel like some users would be confused about creating "post" for a an event, and then having to write the date in a custom field at the bottom.

Can I get my theme to create it's own table in the wp database? Can I avoid that and make my own "instert gig" interface that creates a custom post type, but with an easier to understand "date, venue, about" way of inputting the info?

I don't need a FULL walk-through, but a point in the right direction would be great :)

share|improve this question
    
I just read the last line of the question after posting this very long detailed step by step tutorial like answer :) –  Bainternet Feb 28 '12 at 22:14

3 Answers 3

up vote 8 down vote accepted

Create a custom post type named Gig and WordPress will take care of the UI creation, then all that is left for you is to add a metabox with the fields you want(date, venue, about).

here is a simple step by step:

First register your gig post type:

//register your custom post type gig
add_action( 'init', 'register_cpt_gig' );
function register_cpt_gig() {
    $labels = array( 
        'name' => _x( 'gigs', 'gig' ),
        'singular_name' => _x( 'gig', 'gig' ),
        'add_new' => _x( 'Add New', 'gig' ),
        'add_new_item' => _x( 'Add New gig', 'gig' ),
        'edit_item' => _x( 'Edit gig', 'gig' ),
        'new_item' => _x( 'New gig', 'gig' ),
        'view_item' => _x( 'View gig', 'gig' ),
        'search_items' => _x( 'Search gigs', 'gig' ),
        'not_found' => _x( 'No gigs found', 'gig' ),
        'not_found_in_trash' => _x( 'No gigs found in Trash', 'gig' ),
        'parent_item_colon' => _x( 'Parent gig:', 'gig' ),
        'menu_name' => _x( 'Gigs', 'gig' ),
    );

    $args = array( 
        'labels' => $labels,
        'hierarchical' => false,
        'description' => 'just a simple "where, when, with who" kind of thing',
        'supports' => array( 'title', 'custom-fields' ),

        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,

        'menu_icon' => 'http://i.imgur.com/4nTMD.png',
        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => true,
        'capability_type' => 'post'
    );

    register_post_type( 'gig', $args );
}

this will give you a new post type and an admin UI for creating you gigs: enter image description here

Then you need to create you metabox (to avoid using the regular custom fields) there are a million tutorials online on how to create and add your metabox so I'm not going into that but I'll show you a fast easy way to do it.

download this class and once you put this in your theme the creation of the metabox should be something like this:

if (is_admin()){
    //include the main class file
    require_once("meta-box-class/my-meta-box-class.php");
    $prefix = '_gigs';

    //configure your meta box
    $config = array(
        'id' => 'gigs-info',
        'title' => 'Gig Info',
        'pages' => array('gig'),
        'context' => 'normal', 
        'priority' => 'high', 
        'fields' => array(), 
        'local_images' => false,
        'use_with_theme' => false //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
    );
    $my_meta = new AT_Meta_Box($config);

    //Add fields to your meta box
    $my_meta->addText($prefix.'where',array('name'=> 'Where is the Gig '));
    $my_meta->addDate($prefix.'when',array('name'=> 'When is the Gig '));
    $my_meta->addTime($prefix.'start_time',array('name'=> 'When Does it Start '));
    $my_meta->addTime($prefix.'end_time',array('name'=> 'When Does it End '));
    $my_meta->addText($prefix.'with_who',array('name'=> 'With Who is the Gig '));
    $my_meta->addTextarea($prefix.'words',array('name'=> 'A few words on the gig '));
    $my_meta->Finish();
}

and you get something like this:

enter image description here

another image to show the fancy timepicker enter image description here

To read more on the field types you can use and add to your metabox read this

that's about it, just to wrap I'm posting this as a plugin to test, but make sure you download the metabox class so it will work

<?php
/*
Plugin Name: wp-gigs
Plugin URI: http://en.bainternet.info
Description: create list of gigs.
Version: 0.1
Author: Bainternet
Author URI: http://en.bainternet.info
*/

//register your custom post type gig
add_action( 'init', 'register_cpt_gig' );
function register_cpt_gig() {
    $labels = array( 
        'name' => _x( 'gigs', 'gig' ),
        'singular_name' => _x( 'gig', 'gig' ),
        'add_new' => _x( 'Add New', 'gig' ),
        'add_new_item' => _x( 'Add New gig', 'gig' ),
        'edit_item' => _x( 'Edit gig', 'gig' ),
        'new_item' => _x( 'New gig', 'gig' ),
        'view_item' => _x( 'View gig', 'gig' ),
        'search_items' => _x( 'Search gigs', 'gig' ),
        'not_found' => _x( 'No gigs found', 'gig' ),
        'not_found_in_trash' => _x( 'No gigs found in Trash', 'gig' ),
        'parent_item_colon' => _x( 'Parent gig:', 'gig' ),
        'menu_name' => _x( 'Gigs', 'gig' ),
    );

    $args = array( 
        'labels' => $labels,
        'hierarchical' => false,
        'description' => 'just a simple "where, when, with who" kind of thing',
        'supports' => array( 'title', 'custom-fields' ),

        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,

        'menu_icon' => 'http://i.imgur.com/4nTMD.png',
        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => true,
        'capability_type' => 'post'
    );

    register_post_type( 'gig', $args );
}

if (is_admin()){
    //include the main class file
    require_once("meta-box-class/my-meta-box-class.php");
    $prefix = '_gigs';

    //configure your meta box
    $config = array(
        'id' => 'gigs-info',
        'title' => 'Gig Info',
        'pages' => array('gig'),
        'context' => 'normal', 
        'priority' => 'high', 
        'fields' => array(), 
        'local_images' => false,
        'use_with_theme' => false //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
    );
    $my_meta = new AT_Meta_Box($config);

    //Add fields to your meta box
    $my_meta->addText($prefix.'where',array('name'=> 'Where is the Gig '));
    $my_meta->addDate($prefix.'when',array('name'=> 'When is the Gig '));
    $my_meta->addTime($prefix.'start_time',array('name'=> 'When Does it Start '));
    $my_meta->addTime($prefix.'end_time',array('name'=> 'When Does it End '));
    $my_meta->addText($prefix.'with_who',array('name'=> 'With Who is the Gig '));
    $my_meta->addTextarea($prefix.'words',array('name'=> 'A few words on the gig '));
    $my_meta->Finish();
}
share|improve this answer
    
wow! I was not expecting such an incredible answer. The Karma will definitely repay you one way or another :)! I've got it working, but I don't think I've got the files in the right place. The I only get text fileds for the date and time. Where does the meta-box folder go? –  marctain Feb 28 '12 at 23:50
    
you don't need all of the files, just copy the folder named meta-box-class to the plugin's folder. –  Bainternet Feb 29 '12 at 0:30
    
Oh yea and make sure you are connected to the internet :) since it loads the javascript from a cdn –  Bainternet Feb 29 '12 at 0:32
    
cool thanks a lot my man! :) –  marctain Feb 29 '12 at 0:38
    
I get this error when I try to activate the plugin.. " Warning: require_once(meta-box-class/my-meta-box-class.php) [function.require-once]: failed to open stream: No such file or directory in /Users/marcbeland/Documents/WebSites/Phil's wordpress/wp-content/plugins/meta-box-class/class-usage-demo.php on line 12" –  marctain Feb 29 '12 at 0:54

I've used GigPress before and it works really well.

http://gigpress.com/

share|improve this answer
    
cool. Maybe I'll see how they did it. Although it might be a perfectly viable option, I want to incorporate it in my own theme. –  marctain Feb 28 '12 at 21:58

Might I suggest Event Organiser?

Full disclosure: this is a plug-in I've developed

It essentially does what you are attempting to achieve (creates a custom post type), allows date selection, venues and custom fields so it can be extended for your own particular use.

As for incorporating it into your theme, there are four basic 'example' templates the plug-in comes with. Just copy these into your theme folder and you can edit them however you like, making use of the template functions that come with the plug-in to display event/venue details.

share|improve this answer

Your Answer

 
discard

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.