I was trying to customize my WordPress, and I have added some custom meta boxes (it adds custom field) to add values in it, but I don't know how to do this one...

I want to a Meta Box, which will be a drop down menu. The value of this metabox will determine which sidebar to use in the post. Here's the picture:

enter image description here

closed as too broad by Nicolai, Johannes Pille, s_ha_dum Apr 2 '14 at 12:47

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    There are some solutions available to add a template selector to posts and custom post types. For example the one mentioned in this answer or this one. Surely there are more, but those you have to research yourself. If you want some more and concrete help here, you should improve your question, best with some code - see How to Ask for some help. Good luck! – Nicolai Apr 2 '14 at 11:15

Install metabox plugin and active:

/**** Add this code in your function.php ****/

$meta_boxes[] = array(
    'id' => 'post_sidebar',         
    'title' => 'post Sidebar',      
    'pages' => array('post'),       
    'priority' => 'low',            
    'fields' => array(          
                'name' => 'Post Sidebar',               
                 'id' => 'post_sidebar',        
                 'type' => 'select',                            
                 "options" => array( "0" => "OFF", "1" => "Left side", "2" => "Right Side"),
if ( class_exists( 'RW_Meta_Box' ) )
    foreach ( $meta_boxes as $meta_box )
        new RW_Meta_Box( $meta_box );

/**** after single.php on get value using this one option ****/  

$sidebar_value = get_post_meta($post->ID,'post_sidebar',true);

if($sidebar_value == 1 && $sidebar_value!=0){
    // Add sidebar code for left side

if($sidebar_value=='2' && $sidebar_value!=0){
    // Add sidebar code for right side

enter image description here

  • I know how to add meta boxes, so I changed the function into native metaboxes... Nice idea to use it... ;) – Hardeep Asrani Apr 2 '14 at 11:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.