Jump to content

Recommended Posts

Posted

Hi, I just got done with the Custom Post Type tutorial which was really great at explaining how to further customize WP. I thought I could duplicate what Ben created to build multiple input fields in the Meta Boxes for more content variables. However it didn't quite work. I think I got hung up on the function save_options().

 

Is it possible to post an example of the functions.php file using multiple meta box variables, such as "price", "artist", "dimensions", "year", etc...

 

Thanks for any advice on this matter.

 

Here's what I wrote but didn't work:

 

 

 

// inputs

 

function product_options()

 

{

global $post;

$custom = get_post_custom($post->ID);

$price = $custom['price'][0];

$artist = $custom['artist'][0];

$artist = $custom['year'][0];

 

echo '<label style="padding-right:40px;">Price:</label>

<input name="price" value="'. $price . '" style="width:250px;" />

<br>';

 

echo '<label style="padding-right:40px;">Artist:</label>

<input name="price" value="'. $artist . '" style="width:250px;" />

<br>';

 

echo '<label style="padding-right:40px;">Year:</label>

<input name="price" value="'. $year . '" style="width:250px;" />

<br>';

}

 

 

function save_options() // saves inputs

{

 

 

global $post;

if (!isset($_POST['price'], $_POST['artist'], $_POST['year'] )|| $post->post_type != 'product')

{

return $post;

}

 

update_post_meta($post->ID,"price", $_POST['price']);

update_post_meta($post->ID,"artist", $_POST['artist']);

update_post_meta($post->ID,"artist", $_POST['year']);

 

 

}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...