從我瞭解你的問題,你正在尋找一個簡單的解決方案來自動輸入過程。我有一個大概的想法,因爲我不得不在小冊子類型的網站上做類似的事情。
我試過使用jquery回答你的問題,但我發現它增加了創建你的帖子時所需的文本輸入量,不幸的是沒有完全自動化的方法,但希望在下面提供一個解決方案。
首先我發現下面的插件:類型 - 在這裏自定義字段類型和完整的解決方案:http://wordpress.org/extend/plugins/types/
這允許你創建一個新的職位/頁時創建自定義元精密組件。自定義域添加了「wpcf-」的前綴,然後添加該域的名稱,例如「Episode Name」在數據庫中變成「wpcf-episode-name」。
以下是WordPress的的get_meta功能的編輯:
function get_specifications(){
if ($keys = get_post_custom_keys()) {
echo '<div class="entry_specifications">';
foreach ((array) $keys as $key) {
$keyt = trim($key);
if ('_' == $keyt[0])
continue;
$values = array_map('trim', get_post_custom_values($key));
$value = implode($values,', ');
//remove "wpcf-"
$key = str_replace('wpcf-','',$key);
//convert "-" to a space " "
$key = str_replace('-',' ',$key);
//check if it has a value, continue if it does, skip if it doesn't:
if ($value <> ''){
echo apply_filters('the_meta_key', "
<div class='meta_wrapper'>
<div class='meta_title'>$key</div>
<div class='meta_value'>$value</div>
</div>\n", $key, $value);
};
}
}
// echo '</div>'; comment out and remove the line below if you are not using floats in your css
echo '</div><div class="clear"></div>';
}
在我的page.php文件(或您的模板page.php文件)我已經添加以下代碼何時/何想元被製作:
<?php
//check to see if there is meta data, as you only want the meta data on TV Program pages
$met_check = get_post_meta($post->ID, 'wpcf-features', true);
if ($met_check <> ''){
//if it has a value, spit out "About EpisodeName" ?>
<h2 class="post-title clear">About <?php echo $title ?></h2>
<?php //perform the function from functions.php and return results:
echo get_specifications();
}
?>
我的風格與下面的CSS結果:
.meta_entry {
clear:both;
}
.meta_title {
float:left;
text-transform:capitalize;
width:200px;
}
.meta_value {
float:left;
width:480px;
}
希望這^ h elps隊友!