Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End [WP] – Custom Post Types Custom Fields

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #29635

    Can I modify the title field in a custom post type. My type is football players so instead of ‘title’ I would like there to be these three fields in one line, ‘Number’, ‘First Name’, and ‘Last Name’. Is this possible?

    Thanks.

    #79816
    Rob MacKay
    Participant
    #79854

    Well I wanted to customize the write panel for this specific post type that I created. I know that you can customize the write panel I just don’t know how. Does anyone know how?

    #79877
    TheDoc
    Member
    "acondiff" wrote:
    Well I wanted to customize the write panel for this specific post type that I created. I know that you can customize the write panel I just don’t know how. Does anyone know how?

    You can completely rework the entire write panel, unfortunately I have yet to find a really good tutorial/article that explains it all!

    If you find anything, let us know!

    #79880

    This seems to work (somewhat).

    Code:
    // Create New Post Types

    add_action(‘init’, ‘create_message_post_type’);
    add_action(‘init’, ‘create_game_post_type’);
    add_action(‘init’, ‘create_player_post_type’);

    function create_message_post_type() {
    register_post_type (
    ‘messages’, array (
    ‘labels’ => array (
    ‘name’ => ‘Messages’,
    ‘singular_name’ => ‘Message’,
    ‘add_new’ => ‘Add New Message’,
    ‘add_new_item’ => ‘Add New Message’,
    ‘edit’ => ‘Edit Message’,
    ‘edit_item’ => ‘Edit Message’,
    ‘new_item’ => ‘New Message’,
    ‘view’ => ‘View Message’,
    ‘view_item’ => ‘View Message’,
    ‘search_items’ => ‘Search Messages’,
    ‘not_found’ => ‘No messages found’,
    ‘not_found_in_trash’ => ‘No messages found in Trash’,
    ),
    ‘supports’ => array (
    ‘title’,
    ‘editor’,
    ‘thumbnail’,
    ‘excerpts’,
    ‘comments’,
    ‘revisions’
    ),
    ‘public’ => true,
    ‘rewrite’ => false,
    ‘query_var’ => true,
    ‘menu_position’ => 4
    )
    );
    }

    function create_game_post_type() {
    register_post_type (
    ‘games’, array (
    ‘labels’ => array (
    ‘name’ => ‘Games’,
    ‘singular_name’ => ‘Game’,
    ‘add_new’ => ‘Add New Game’,
    ‘add_new_item’ => ‘Add New Game’,
    ‘edit’ => ‘Edit Games’,
    ‘edit_item’ => ‘Edit Game’,
    ‘new_item’ => ‘New Game’,
    ‘view’ => ‘View Game’,
    ‘view_item’ => ‘View Game’,
    ‘search_items’ => ‘Search Games’,
    ‘not_found’ => ‘No games found’,
    ‘not_found_in_trash’ => ‘No games found in Trash’,
    ),
    ‘supports’ => array (
    ‘title’,
    ‘editor’,
    ‘thumbnail’,
    ‘excerpts’,
    ‘comments’,
    ‘revisions’
    ),
    ‘public’ => true,
    ‘rewrite’ => false,
    ‘query_var’ => true,
    ‘menu_position’ => 5
    )
    );
    }

    function create_player_post_type() {
    register_post_type (
    ‘players’, array (
    ‘labels’ => array (
    ‘name’ => ‘Roster’,
    ‘singular_name’ => ‘Player’,
    ‘add_new’ => ‘Add New Player’,
    ‘add_new_item’ => ‘Add New Player’,
    ‘edit’ => ‘Edit Roster’,
    ‘edit_item’ => ‘Edit Player’,
    ‘new_item’ => ‘New Player’,
    ‘view’ => ‘View Player’,
    ‘view_item’ => ‘View Player’,
    ‘search_items’ => ‘Search Players’,
    ‘not_found’ => ‘No players found’,
    ‘not_found_in_trash’ => ‘No players found in Trash’,
    ),
    ‘supports’ => array (
    ‘title’,
    ‘thumbnail’
    ),
    ‘public’ => true,
    ‘rewrite’ => false,
    ‘query_var’ => true,
    ‘menu_position’ => 6
    )
    );
    }

    // Create Taximonies
    add_action( ‘init’, ‘create_team_taxonomies’ );
    function create_team_taxonomies() {
    register_taxonomy (
    ‘teams’,
    array( ‘messages’,’games’,’players’ ),
    array (
    ‘labels’ => array (
    ‘name’ => ‘Teams’,
    ‘singular_name’ => ‘Team’,
    ‘search_items’ => ‘Search Teams’,
    ‘popular_items’ => ‘Popular Teams’,
    ‘all_items’ => ‘All Teams’,
    ‘parent_item’ => ‘Parent Teams’,
    ‘parent_item_colon’ => ‘Parent Teams:’,
    ‘edit_item’ => ‘Edit Team’,
    ‘update_item’ => ‘Update Team’,
    ‘add_new_item’ => ‘Add New Team’,
    ‘new_item_name’ => ‘New Team Name’
    ),
    ‘hierarchical’ => true,
    ‘public’ => true,
    ‘show_ui’ => true,
    ‘query_var’ => ”,
    ‘show_tagcloud’ => true,
    )
    );
    }

    //Create Meta Boxes

    $key = "key";
    $meta_boxes = array(
    "number" => array(
    "name" => "number",
    "title" => "Number",
    "description" => "",
    "type" => "text",
    "class" => "text",
    "rows" => "",
    "width" => "100%",
    "options" => ""
    ),
    "first_name" => array(
    "name" => "first_name",
    "title" => "First Name",
    "description" => "",
    "type" => "text",
    "class" => "text",
    "rows" => "",
    "width" => "100%",
    "options" => ""
    ),
    "last_name" => array(
    "name" => "last_name",
    "title" => "Last Name",
    "description" => "",
    "type" => "text",
    "class" => "text",
    "rows" => "",
    "width" => "100%",
    "options" => ""
    ),
    "height" => array(
    "name" => "height",
    "title" => "Height",
    "description" => "",
    "type" => "text",
    "class" => "text",
    "rows" => "",
    "width" => "100%",
    "options" => ""
    ),
    "weight" => array(
    "name" => "weight",
    "title" => "Weight",
    "description" => "",
    "type" => "text",
    "class" => "text",
    "rows" => "",
    "width" => "100%",
    "options" => ""
    ),
    "position" => array(
    "name" => "position",
    "title" => "Position",
    "description" => "",
    "type" => "text",
    "class" => "text",
    "rows" => "",
    "width" => "100%",
    "options" => ""
    ),
    "grade" => array(
    "name" => "grade",
    "title" => "Grade",
    "description" => "This is an example for a regular input field.",
    "type" => "text",
    "class" => "text",
    "rows" => "",
    "width" => "100%",
    "options" => ""
    ),
    "bio" => array(
    "name" => "bio",
    "title" => "Bio",
    "description" => "",
    "type" => "textarea",
    "class" => "textarea",
    "rows" => "6",
    "width" => "100%",
    "options" => ""
    ),
    );

    function create_meta_box() {
    global $key;

    if( function_exists( ‘add_meta_box’ ) ) {
    add_meta_box( ‘new-meta-boxes’, ‘Player Details’, ‘display_meta_box’, ‘players’, ‘normal’, ‘high’ );
    }
    }

    function display_meta_box() {
    global $post, $meta_boxes, $key;

    wp_nonce_field( plugin_basename( __FILE__ ), $key . ‘_wpnonce’, false, true );

    $output = ”;
    foreach($meta_boxes as $meta_box) {
    $data = get_post_meta($post->ID, $key, true);

    $output .= ‘<p style="font-size:1.1em; font-style:normal;">’ . $meta_box[’title’] . ‘<br />’ . "n";

    if($meta_box[’type’] == ‘text’) { // plain text input
    $output .= ‘<input type="text" name="’ . $meta_box[’name’] . ‘" value="’ . $data[$meta_box[’name’]] . ‘" style="width:’ . $meta_box[’width’] . ‘;" />’;
    }

    else if($meta_box[’type’] == ‘textarea’) { // textarea box
    $output .= ‘<textarea name="’ . $meta_box[’name’] . ‘" style="width:’ . $meta_box[’width’] . ‘; height:100px;">’ . $data[$meta_box[’name’]] . ‘</textarea>’;
    }

    else if(($meta_box[’type’] == ‘checkbox’) && (!empty($meta_box[’options’]))) { // checkboxes
    foreach($meta_box[’options’] as $checkbox_value) {
    if($data[$meta_box[’name’]] != "") { // if array is empty, warnings will be issued, this circumvents it
    $output .= ‘<input type="checkbox" name="’ . $meta_box[’name’] . ‘[]" value="’ . $checkbox_value . ‘" ‘ . (isset($data[$meta_box[’name’]]) && (in_array($checkbox_value, $data[$meta_box[’name’]])) ? ‘ checked="checked"’ : ”) . ‘/> ‘ . $checkbox_value . ‘ &nbsp; ‘ . "n";
    } else {
    $output .= ‘<input type="checkbox" name="’ . $meta_box[’name’] . ‘[]" value="’ . $checkbox_value . ‘"/> ‘ . $checkbox_value . ‘ &nbsp; ‘ . "n";
    }
    }
    }

    else if(($meta_box[’type’] == ‘radio’) && (!empty($meta_box[’options’]))) { // radio buttons

    foreach($meta_box[’options’] as $radio_value) {
    $output .= ‘<input type="radio" name="’ . $meta_box[’name’] . ‘" value="’ . $radio_value . ‘" ‘ . (isset($data[$meta_box[’name’]]) && ($data[$meta_box[’name’]] == $radio_value) ? ‘ checked="checked"’ : ”) . ‘/> ‘ . $radio_value . ‘ &nbsp; ‘ . "n";
    }
    }

    else if(($meta_box[’type’] == ‘dropdown’) && (!empty($meta_box[’options’]))) { // dropdown lists

    $output .= ‘<select name="’ . $meta_box[’name’] . ‘">’ . "n";
    if (isset($data[$meta_box[’name’]])) {
    $output .= ‘<option selected>’. $data[$meta_box[’name’]] .'</option>’ . "n";
    }

    $output .= ‘<option value="">—————-</option>’ . "n";
    foreach($meta_box[’options’] as $dropdown_key => $dropdown_value) {
    $output .= ‘<option value="’ . $dropdown_value . ‘">’ . $dropdown_value . ‘</option>’ . "n";
    }

    $output .= ‘</select>’ . "n";
    }

    $output .= "</p>nn";
    }

    echo ‘<div>’ . "n" . $output . "n" . ‘</div>’ . "nn";

    }

    function save_meta_box( $post_id ) {
    global $post, $meta_boxes, $key;

    foreach( $meta_boxes as $meta_box ) {
    $data[ $meta_box[ ‘name’ ] ] = $_POST[ $meta_box[ ‘name’ ] ];
    }

    if ( !wp_verify_nonce( $_POST[ $key . ‘_wpnonce’ ], plugin_basename(__FILE__) ) )
    return $post_id;

    if ( !current_user_can( ‘edit_post’, $post_id ))
    return $post_id;

    update_post_meta( $post_id, $key, $data );
    }

    add_action( ‘admin_menu’, ‘create_meta_box’ );
    add_action( ‘save_post’, ‘save_meta_box’ );

    First of all, I want to get it out of a foreach statement so I can Format each textbox in its own way (different widths, two on same line, etc.)

    Secondly, I am trying to figure out how to make a second meta box for the next post type.

    Third, I am trying to rewrite the permalink to reflect a textbox in my new metabox. In that post type, I got rid of the title field so I need to rewrite the permalink in order for each pots permalink to be unique.

    Any help would be great and I will update y’all on anything I can figure out.

    Thanks.

    #79886

    I figured out how to have a different meta box for each post type. I just need to figure out how to rewrite the permalink…

    here is the code:

    Code:
    // Create New Post Types

    add_action(‘init’, ‘create_message_post_type’);
    add_action(‘init’, ‘create_game_post_type’);
    add_action(‘init’, ‘create_player_post_type’);

    function create_message_post_type() {
    register_post_type (
    ‘messages’, array (
    ‘labels’ => array (
    ‘name’ => ‘Messages’,
    ‘singular_name’ => ‘Message’,
    ‘add_new’ => ‘Add New Message’,
    ‘add_new_item’ => ‘Add New Message’,
    ‘edit’ => ‘Edit Message’,
    ‘edit_item’ => ‘Edit Message’,
    ‘new_item’ => ‘New Message’,
    ‘view’ => ‘View Message’,
    ‘view_item’ => ‘View Message’,
    ‘search_items’ => ‘Search Messages’,
    ‘not_found’ => ‘No messages found’,
    ‘not_found_in_trash’ => ‘No messages found in Trash’,
    ),
    ‘supports’ => array (
    ‘title’,
    ‘editor’,
    ‘thumbnail’,
    ‘excerpts’,
    ‘comments’,
    ‘revisions’
    ),
    ‘public’ => true,
    ‘rewrite’ => false,
    ‘query_var’ => true,
    ‘menu_position’ => 4
    )
    );
    }

    function create_game_post_type() {
    register_post_type (
    ‘games’, array (
    ‘labels’ => array (
    ‘name’ => ‘Games’,
    ‘singular_name’ => ‘Game’,
    ‘add_new’ => ‘Add New Game’,
    ‘add_new_item’ => ‘Add New Game’,
    ‘edit’ => ‘Edit Games’,
    ‘edit_item’ => ‘Edit Game’,
    ‘new_item’ => ‘New Game’,
    ‘view’ => ‘View Game’,
    ‘view_item’ => ‘View Game’,
    ‘search_items’ => ‘Search Games’,
    ‘not_found’ => ‘No games found’,
    ‘not_found_in_trash’ => ‘No games found in Trash’,
    ),
    ‘supports’ => array (
    ‘title’,
    ‘editor’,
    ‘thumbnail’,
    ‘excerpts’,
    ‘comments’,
    ‘revisions’
    ),
    ‘public’ => true,
    ‘rewrite’ => false,
    ‘query_var’ => true,
    ‘menu_position’ => 5
    )
    );
    }

    function create_player_post_type() {
    register_post_type (
    ‘players’, array (
    ‘labels’ => array (
    ‘name’ => ‘Roster’,
    ‘singular_name’ => ‘Player’,
    ‘add_new’ => ‘Add New Player’,
    ‘add_new_item’ => ‘Add New Player’,
    ‘edit’ => ‘Edit Roster’,
    ‘edit_item’ => ‘Edit Player’,
    ‘new_item’ => ‘New Player’,
    ‘view’ => ‘View Player’,
    ‘view_item’ => ‘View Player’,
    ‘search_items’ => ‘Search Players’,
    ‘not_found’ => ‘No players found’,
    ‘not_found_in_trash’ => ‘No players found in Trash’,
    ),
    ‘supports’ => array (

    ),
    ‘public’ => true,
    ‘rewrite’ => false,
    ‘query_var’ => true,
    ‘menu_position’ => 6
    )
    );
    }

    // Create Taximonies
    add_action( ‘init’, ‘create_team_taxonomies’ );
    function create_team_taxonomies() {
    register_taxonomy (
    ‘teams’,
    array( ‘messages’,’games’,’players’ ),
    array (
    ‘labels’ => array (
    ‘name’ => ‘Teams’,
    ‘singular_name’ => ‘Team’,
    ‘search_items’ => ‘Search Teams’,
    ‘popular_items’ => ‘Popular Teams’,
    ‘all_items’ => ‘All Teams’,
    ‘parent_item’ => ‘Parent Teams’,
    ‘parent_item_colon’ => ‘Parent Teams:’,
    ‘edit_item’ => ‘Edit Team’,
    ‘update_item’ => ‘Update Team’,
    ‘add_new_item’ => ‘Add New Team’,
    ‘new_item_name’ => ‘New Team Name’
    ),
    ‘hierarchical’ => true,
    ‘public’ => true,
    ‘show_ui’ => true,
    ‘query_var’ => ”,
    ‘show_tagcloud’ => true,
    )
    );
    }

    //Create Meta Boxes

    $prefix = ‘dbt_’;

    $meta_boxes = array();

    // first meta box
    $meta_boxes[] = array(
    ‘id’ => ‘player_details’,
    ‘title’ => ‘Player Details’,
    ‘pages’ => array(‘players’), // multiple post types
    ‘context’ => ‘normal’,
    ‘priority’ => ‘high’,
    ‘fields’ => array(
    array(
    ‘name’ => ‘First Name’,
    ‘desc’ => ”,
    ‘id’ => $prefix . ‘text’,
    ‘type’ => ‘text’, // text box
    ‘std’ => ”
    ),
    array(
    ‘name’ => ‘Last Name’,
    ‘desc’ => ”,
    ‘id’ => $prefix . ‘last_name’,
    ‘type’ => ‘text’, // text box
    ‘std’ => ”
    ),
    array(
    ‘name’ => ‘Height’,
    ‘desc’ => ”,
    ‘id’ => $prefix . ‘height’,
    ‘type’ => ‘text’, // text box
    ‘std’ => ”
    ),
    array(
    ‘name’ => ‘Weight’,
    ‘desc’ => ”,
    ‘id’ => $prefix . ‘weight’,
    ‘type’ => ‘text’, // text box
    ‘std’ => ”
    ),
    array(
    ‘name’ => ‘Number’,
    ‘desc’ => ”,
    ‘id’ => $prefix . ‘number’,
    ‘type’ => ‘text’, // text box
    ‘std’ => ”
    ),
    array(
    ‘name’ => ‘Position’,
    ‘desc’ => ”,
    ‘id’ => $prefix . ‘position’,
    ‘type’ => ‘text’, // text box
    ‘std’ => ”
    ),
    array(
    ‘name’ => ‘Grade’,
    ‘id’ => $prefix . ‘select’,
    ‘type’ => ‘select’, // select box
    ‘options’ => array(‘Please select grade’, ‘Freshman’, ‘Sophomore’, ‘Junior’, ‘Senior’, ‘Graduate’) // array of options for select box
    ),
    array(
    ‘name’ => ‘Bio’,
    ‘desc’ => ”,
    ‘id’ => $prefix . ‘bio’,
    ‘type’ => ‘textarea’, // text area
    ‘std’ => ‘Insert players biography here...’
    ),
    array(
    ‘name’ => ‘Photo’,
    ‘desc’ => ”,
    ‘id’ => $prefix . ‘photo’,
    ‘type’ => ‘image’ // image upload
    ),

    )
    );

    // second meta box
    $meta_boxes[] = array(
    ‘id’ => ‘game_details’,
    ‘title’ => ‘Game Details’,
    ‘pages’ => array(‘games’), // custom post types, since WordPress 3.0
    ‘context’ => ‘normal’,
    ‘priority’ => ‘high’,
    ‘fields’ => array(
    array(
    ‘name’ => ‘Opponent’,
    ‘desc’ => ”,
    ‘id’ => $prefix . ‘opponent’,
    ‘type’ => ‘text’, // text box
    ‘std’ => ”
    ),
    array(
    ‘name’ => ‘Game Date’,
    ‘desc’ => ”,
    ‘id’ => $prefix . ‘date’,
    ‘type’ => ‘text’, // text box
    ‘std’ => ”
    ),
    array(
    ‘name’ => ‘Time’,
    ‘desc’ => ”,
    ‘id’ => $prefix . ‘time’,
    ‘type’ => ‘text’, // text box
    ‘std’ => ”
    ),
    array(
    ‘name’ => ‘Home / Away’,
    ‘id’ => $prefix . ‘home_away’,
    ‘type’ => ‘radio’, // radio box
    ‘options’ => array( // array of name, value pairs for radio options
    array(‘name’ => ‘Home’, ‘value’ => ‘Home’),
    array(‘name’ => ‘Away’, ‘value’ => ‘Away’)
    )
    ),
    array(
    ‘name’ => ‘City’,
    ‘desc’ => ”,
    ‘id’ => $prefix . ‘city’,
    ‘type’ => ‘text’, // text box
    ‘std’ => ”
    ),
    array(
    ‘name’ => ‘State’,
    ‘desc’ => ”,
    ‘id’ => $prefix . ‘state’,
    ‘type’ => ‘text’, // text box
    ‘std’ => ”
    ),
    array(
    ‘name’ => ‘Oak’s Score’,
    ‘desc’ => ”,
    ‘id’ => $prefix . ‘oak_score’,
    ‘type’ => ‘text’, // text box
    ‘std’ => ”
    ),
    array(
    ‘name’ => ‘Opponent’s Score’,
    ‘desc’ => ”,
    ‘id’ => $prefix . ‘opp_score’,
    ‘type’ => ‘text’, // text box
    ‘std’ => ”
    ),
    )
    );

    /*********************************

    You should not edit the code below

    *********************************/

    foreach ($meta_boxes as $meta_box) {
    $my_box = new My_meta_box($meta_box);
    }

    class My_meta_box {

    protected $_meta_box;

    // create meta box based on given data
    function __construct($meta_box) {
    if (!is_admin()) return;

    $this->_meta_box = $meta_box;

    // fix upload bug: http://www.hashbangcode.com/blog/add-enctype-wordpress-post-and-page-forms-471.html
    $current_page = substr(strrchr($_SERVER[’PHP_SELF’], ‘/’), 1, -4);
    if ($current_page == ‘page’ || $current_page == ‘page-new’ || $current_page == ‘post’ || $current_page == ‘post-new’) {
    add_action(‘admin_head’, array(&$this, ‘add_post_enctype’));
    }

    add_action(‘admin_menu’, array(&$this, ‘add’));

    add_action(‘save_post’, array(&$this, ‘save’));
    }

    function add_post_enctype() {
    echo ‘
    <script type="text/javascript">
    jQuery(document).ready(function(){
    jQuery("#post").attr("enctype", "multipart/form-data");
    jQuery("#post").attr("encoding", "multipart/form-data");
    });
    </script>’;
    }

    /// Add meta box for multiple post types
    function add() {
    foreach ($this->_meta_box[’pages’] as $page) {
    add_meta_box($this->_meta_box[’id’], $this->_meta_box[’title’], array(&$this, ‘show’), $page, $this->_meta_box[’context’], $this->_meta_box[’priority’]);
    }
    }

    // Callback function to show fields in meta box
    function show() {
    global $post;

    // Use nonce for verification
    echo ‘<input type="hidden" name="mytheme_meta_box_nonce" value="’, wp_create_nonce(basename(__FILE__)), ‘" />’;

    echo ‘<table class="form-table">’;

    foreach ($this->_meta_box[’fields’] as $field) {
    // get current post meta data
    $meta = get_post_meta($post->ID, $field[’id’], true);

    echo ‘<tr>’,
    ‘<th style="width:20%"><label for="’, $field[’id’], ‘">’, $field[’name’], ‘</label></th>’,
    ‘<td>’;
    switch ($field[’type’]) {
    case ‘text’:
    echo ‘<input type="text" name="’, $field[’id’], ‘" id="’, $field[’id’], ‘" value="’, $meta ? $meta : $field[’std’], ‘" size="30" style="width:97%" />’,
    ‘<br />’, $field[’desc’];
    break;
    case ‘textarea’:
    echo ‘<textarea name="’, $field[’id’], ‘" id="’, $field[’id’], ‘" cols="60" rows="4" style="width:97%">’, $meta ? $meta : $field[’std’], ‘</textarea>’,
    ‘<br />’, $field[’desc’];
    break;
    case ‘select’:
    echo ‘<select name="’, $field[’id’], ‘" id="’, $field[’id’], ‘">’;
    foreach ($field[’options’] as $option) {
    echo ‘<option’, $meta == $option ? ‘ selected="selected"’ : ”, ‘>’, $option, ‘</option>’;
    }
    echo ‘</select>’;
    break;
    case ‘radio’:
    foreach ($field[’options’] as $option) {
    echo ‘<input type="radio" name="’, $field[’id’], ‘" value="’, $option[’value’], ‘"’, $meta == $option[’value’] ? ‘ checked="checked"’ : ”, ‘ />’, $option[’name’];
    }
    break;
    case ‘checkbox’:
    echo ‘<input type="checkbox" name="’, $field[’id’], ‘" id="’, $field[’id’], ‘"’, $meta ? ‘ checked="checked"’ : ”, ‘ />’;
    break;
    case ‘file’:
    echo $meta ? "$meta<br />" : ”, ‘<input type="file" name="’, $field[’id’], ‘" id="’, $field[’id’], ‘" />’,
    ‘<br />’, $field[’desc’];
    break;
    case ‘image’:
    echo $meta ? "<img src="$meta" width="150" height="150" /><br />$meta<br />" : ”, ‘<input type="file" name="’, $field[’id’], ‘" id="’, $field[’id’], ‘" />’,
    ‘<br />’, $field[’desc’];
    break;
    }
    echo ‘<td>’,
    ‘</tr>’;
    }

    echo ‘</table>’;
    }

    // Save data from meta box
    function save($post_id) {
    // verify nonce
    if (!wp_verify_nonce($_POST[’mytheme_meta_box_nonce’], basename(__FILE__))) {
    return $post_id;
    }

    // check autosave
    if (defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE) {
    return $post_id;
    }

    // check permissions
    if (‘page’ == $_POST[’post_type’]) {
    if (!current_user_can(‘edit_page’, $post_id)) {
    return $post_id;
    }
    } elseif (!current_user_can(‘edit_post’, $post_id)) {
    return $post_id;
    }

    foreach ($this->_meta_box[’fields’] as $field) {
    $name = $field[’id’];

    $old = get_post_meta($post_id, $name, true);
    $new = $_POST[$field[’id’]];

    if ($field[’type’] == ‘file’ || $field[’type’] == ‘image’) {
    $file = wp_handle_upload($_FILES[$name], array(‘test_form’ => false));
    $new = $file[’url’];
    }

    if ($new && $new != $old) {
    update_post_meta($post_id, $name, $new);
    } elseif (” == $new && $old && $field[’type’] != ‘file’ && $field[’type’] != ‘image’) {
    delete_post_meta($post_id, $name, $old);
    }
    }
    }
    }

    Oh and can I change "Enter Title Here" in the title box, to "Enter Headline Here" for a specific post type?

    #79893

    Regarding the permalink rewrite, I found this: http://wpcandy.com/articles/tutorials/c … ields.html

    I just need a little help implementing it. It looks pretty straight forward, I just need to apply it to one post type instead of all my posts.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Back End’ is closed to new topics and replies.