Попытка добавить пользовательский тип записи, которая была успешной, проблема, с которой я столкнулся, заключается в добавлении metabox и входных данных для этих типов записей, вот код, который я имею:
functions.php
add_action ("admin_init", "admin_init");
function admin_init(){
add_meta_box("deal-meta", "Deal Options", "deal_options", "deal", "side", "low");
}
function deal_options(){
global $post;
$custom = get_post_custom($post->ID);
$price = $custom["price"][0];
$discount = $custom["discount"][0];
$market_value = $custom["market_value"][0];
$start_date = $custom["start_date"][0];
$end_date = $custom["end_date"][0];
$highlights = $custom["highlights"][0];
$fine_print = $custom["fine_print"][0];
$quick_description = $custom["quick_description"][0];
?>
<label>Price:</label>
<input name="price" value="<?php echo $price; ?>" />
<label>Discount:</label>
<input name="discount" value="<?php echo $discount; ?>" />
<label>Market Value:</label>
<input name="market_value" value="<?php echo $market_value; ?>" />
<label>Start Date:</label>
<input name="start_date" value="<?php echo $start_date; ?>" />
<label>End Date:</label>
<input name="end_date" value="<?php echo $end_date; ?>" />
<label>Highlights:</label>
<textarea cols="50" rows="5" name="highlights"><?php echo $highlights; ?></textarea>
<label>Fine Print:</label>
<textarea cols="50" rows="5" name="fine_print"><?php echo $fine_print; ?></textarea>
<label>Quick Description:</label>
<textarea cols="50" rows="5" name="quick_description"><?php echo $quick_description; ?></textarea>
<?php
}
add_action('save_post', 'save_details');
function save_details(){
global $post;
update_post_meta($post->ID, "price", $_POST["price"]);
update_post_meta($post->ID, "discount", $_POST["discount"]);
update_post_meta($post->ID, "market_value", $_POST["market_value"]);
update_post_meta($post->ID, "start_date", $_POST["start_date"]);
update_post_meta($post->ID, "end_date", $_POST["end_date"]);
update_post_meta($post->ID, "highlights", $_POST["highlights"]);
update_post_meta($post->ID, "fine_print", $_POST["fine_print"]);
update_post_meta($post->ID, "quick_description", $_POST["quick_description"]);
}
Однако, когда я иду в Add Deal, он не показывает ничего из этого, запутался.
Любая помощь будет оценена
Спасибо
Dave
Var dump:
array(2) {
["deal"]=>
array(2) {
["side"]=>
array(2) {
["core"]=>
array(2) {
["submitdiv"]=>
array(4) {
["id"]=>
string(9) "submitdiv"
["title"]=>
string(7) "Publish"
["callback"]=>
string(20) "post_submit_meta_box"
["args"]=>
NULL
}
["Citiesdiv"]=>
array(4) {
["id"]=>
string(9) "Citiesdiv"
["title"]=>
string(6) "Cities"
["callback"]=>
string(24) "post_categories_meta_box"
["args"]=>
array(1) {
["taxonomy"]=>
string(6) "Cities"
}
}
}
["low"]=>
array(1) {
["postimagediv"]=>
array(4) {
["id"]=>
string(12) "postimagediv"
["title"]=>
string(14) "Featured Image"
["callback"]=>
string(23) "post_thumbnail_meta_box"
["args"]=>
NULL
}
}
}
["normal"]=>
array(1) {
["core"]=>
array(1) {
["slugdiv"]=>
array(4) {
["id"]=>
string(7) "slugdiv"
["title"]=>
string(4) "Slug"
["callback"]=>
string(18) "post_slug_meta_box"
["args"]=>
NULL
}
}
}
}
["post"]=>
array(1) {
["side"]=>
array(1) {
["low"]=>
array(1) {
["deal-meta"]=>
array(4) {
["id"]=>
string(9) "deal-meta"
["title"]=>
string(12) "Deal Options"
["callback"]=>
string(12) "deal_options"
["args"]=>
NULL
}
}
}
}
}