i’am try to write own plugin but every time i got error or metabox is not show correctly.
this is my plugin code
see the code it displays on top of header. i want to display it below the ‘editor’ box
i tired but not show correctly.
<?php
/*
Plugin Name: party event
Plugin URI: http://careertracker.net
Version: 1.0
Author: Savan Paun
Description: event sample plugin
*/
// Registers the new post type and taxonomy
function wpt_event_posttype() {
register_post_type( 'events',
array(
'labels' => array(
'name' => __( 'Events' ),
'singular_name' => __( 'Event' ),
'add_new' => __( 'Add New Event' ),
'add_new_item' => __( 'Add New Event' ),
'edit_item' => __( 'Edit Event' ),
'new_item' => __( 'Add New Event' ),
'view_item' => __( 'View Event' ),
'search_items' => __( 'Search Event' ),
'not_found' => __( 'No events found' ),
'not_found_in_trash' => __( 'No events found in trash' )
),
'public' => true,
'supports' => array( 'title', 'editor', 'thumbnail', 'comments' ),
'capability_type' => 'post',
'rewrite' => array("slug" => "events"), // Permalinks format
'menu_position' => 5,
'register_meta_box_cb' => 'add_events_metaboxes'
)
);
}
add_action( 'init', 'wpt_event_posttype' );
function add_events_metaboxes()
{
?>
<table width=450 border=1>
<tr>
<td width=139>Foods</td>
<td width=295>
<label for=select></label>
<select name=food id=food>
<option value="Pizza">Pizza</option>
<option value="Hotdog">Hotdog</option>
</select>
</td>
</tr>
<tr>
<td>Tea</td>
<td><select name=tez id=tea>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select></td>
</tr>
<tr>
<td>Person</td>
<td><label for=textfield></label>
<input type=text name=textfield id=textfield /></td>
</tr>
</table>
<?php
}
?>
See full working code below:
The problem is that your
register_meta_box_cb
callback function should be like:And then the function
print_meta_box()
with the HTML output:But maybe you’re looking for something like this (without a meta box and getting rid of
register_meta_box_cb
):