2012-02-15 31 views
2

我有一個產品的自定義帖子類型。我有兩個TinyMCE編輯器(標準和一個摘要字段)在儀表板中正確加載。從事物的儀表板一側,一切工作正常。添加,更新。 etc ...自定義帖子類型中的多個編輯器(TinyMCE)

雖然在網站上,輸出失去了換行符(段落標籤)。這裏有一個例子:

http://keg.brettatkin.com/products/complete-consulting-skills-learning-system/

我使用wp_editor功能這一點。 (http://codex.wordpress.org/Function_Reference/wp_editor)

這裏是我的代碼:

<?php 
function keg_product_fields(){ 
global $post; 
$custom = get_post_custom($post->ID); 
$keg_product_price = $custom["keg_product_price"][0]; 
$keg_product_link = $custom["keg_product_link"][0]; 
$keg_product_type = $custom["keg_product_type"][0]; 
$keg_product_featured = $custom["keg_product_featured"][0]; 
$keg_product_summary = $custom["keg_product_summary"][0]; 
$editor_id = "kegprodsummary" 
?> 
<p> 
<label>Summary:</label><br /> 
<?php wp_editor($keg_product_summary, $editor_id, $settings = array('textarea_name' => 'keg_product_summary')); ?> 
</p> 
<p> 
<label>Price:</label><br /> 
<input size="10" name="keg_product_price" value="<?php echo $keg_product_price; ?>" /> 
</p> 
<p> 
<label>Type:</label><br /> 
<select name="keg_product_type"> 
<option value="<?php echo $keg_product_type; ?>" selected="selected"><?php echo $keg_product_type; ?></option> 
<option value="Book">Book</option> 
<option value="CD">CD</option> 
<option value="Downloadable">Downloadable</option> 
<option value="Multimedia">Multimedia</option> 
<option value="Virtual">Virtual</option> 
</select> 
</p> 
<p> 
<label>Link:</label><br /> 
<input size="65" maxlength="200" name="keg_product_link" value="<?php echo $keg_product_link; ?>" /> 
</p> 
<p> 
<input type="checkbox" name="keg_product_featured" value="Yes" <?php if (!(strcmp("$keg_product_featured","Yes"))) {echo "checked=\"checked\"";} ?>/> 
<label>Featured Product</label> 
</p> 

<?php 
} 

function add_keg_product_box(){ 
add_meta_box(
"keg_product_info", 
"Product Details", 
"keg_product_fields", 
"keg_products" 
); 
} 


function save_keg_product_attributes ($post_id) 
{ 
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { 
return $post_id; 
} 

global $post; 
update_post_meta($post->ID, "keg_product_price", $_POST["keg_product_price"]); 
update_post_meta($post->ID, "keg_product_link", $_POST["keg_product_link"]); 
update_post_meta($post->ID, "keg_product_type", $_POST["keg_product_type"]); 
update_post_meta($post->ID, "keg_product_featured", $_POST["keg_product_featured"]); 
update_post_meta($post->ID, "keg_product_summary", $_POST["keg_product_summary"]); 

} 

add_action ('admin_init', 'add_keg_product_box'); 
add_action ('save_post', 'save_keg_product_attributes'); 
add_action ('publish_post', 'save_keg_product_attributes'); 
?> 

任何想法嗎?

謝謝!

佈雷特

+0

我看不到任何TinyMCE的編輯器,在該頁面 – Thariama 2012-02-16 08:45:39

+0

對不起,該網頁是越來越剝去段落標記的一個例子。這是節省大膽等等。 – Brett 2012-02-16 14:51:50

+0

如果標籤被剝離,你可能不需要調整valid_elements和valid_children的默認設置:http://www.tinymce.com/wiki.php/Configuration:valid_children – Thariama 2012-02-17 08:12:36

回答

0

保存內容或顯示出它時,在使用wpautop()嘗試(我建議你保存的時候使用它,性能)。
此功能根據換行符在整個文本中添加段落。

1

您必須在要顯示摘要的頁面中應用帶有apply_filters功能的輸出過濾器。

例子:

<?php 
$summary = get_post_meta(...); 
echo apply_filters('the_content', $summary); 
?> 
相關問題