从我了解你的问题,你正在寻找一个简单的解决方案来自动输入过程。我有一个大概的想法,因为我不得不在小册子类型的网站上做类似的事情。
我试过使用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队友!