我对此不知所措。您是否看到以下特定于noindex、nofollow复选框的代码有任何错误?元框可以很好地绘制到屏幕上,但值不会粘住。
自定义页面标题和自定义摘录的代码工作正常。
// ===================
// = POST OPTION BOX =
// ===================
add_action(\'admin_menu\', \'my_post_options_box\');
function my_post_options_box() {
if ( function_exists(\'add_meta_box\') ) {
add_meta_box(\'post_header\', \'Custom Post Header Code (optional)\', \'custom_post_images\', \'post\', \'normal\', \'low\');
add_meta_box(\'post_title\', \'Custom Post Title\', \'custom_post_title\', \'post\', \'normal\', \'high\');
add_meta_box(\'post_title_page\', \'Custom Post Title\', \'custom_post_title_page\', \'page\', \'normal\', \'high\');
add_meta_box(\'postexcerpt\', __(\'Excerpt\'), \'post_excerpt_meta_box\', \'page\', \'normal\', \'core\');
add_meta_box(\'categorydiv\', __(\'Page Index Options\'), \'post_categories_meta_box_modified\', \'page\', \'side\', \'high\');
}
}
//Adds the custom images box
function custom_post_images() {
global $post;
?>
<div class="inside">
<textarea style="height:70px; width:100%;margin-left:-5px;" name="cb2_customHeader" id="cb2_customHeader"><?php echo get_post_meta($post->ID, \'cb2_customHeader\', true); ?></textarea>
<p>Enter your custom html code here for the post page header/image area. Whatever you enter here will override the default post header or image listing <b>for this post only</b>. You can enter image references like so <img src=\'wp-content/uploads/product1.jpg\' />. To show default images, just leave this field empty</p>
</div>
<?php
}
//Adds the custom post title box to posts
function custom_post_title() {
global $post;
?>
<div class="inside">
<p><input style="height:25px;width:100%;margin-left:-10px;" type="text" name="cb2_customTitle" id="cb2_customTitle" value="<?php echo get_post_meta($post->ID, \'cb2_customTitle\', true); ?>"></p>
<p>Enter your custom Post Title here and it will be used for the html <title> for this post page and the Google link text used for this page.</p>
</div>
<?php
}
//Adds the custom post title box to pages
function custom_post_title_page() {
global $post;
?>
<div class="inside">
<p><input style="height:25px;width:100%;margin-left:-10px;" type="text" name="cb2_customTitle" id="cb2_customTitle" value="<?php echo get_post_meta($post->ID, \'cb2_customTitle\', true); ?>"></p>
<p>Enter your custom Page Title here and it will be used for the html <title> for this page and the Google link text used for this page.</p>
</div>
<?php
}
//adds the custom categories box
function post_categories_meta_box_modified($post) {
global $post, $noindexCat, $nofollowCat;
$noindexCat = get_cat_ID(\'noindex\');
$nofollowCat = get_cat_ID(\'nofollow\');
if(in_category("noindex")){ $noindexChecked = " checked=\'checked\'";}
if(in_category("nofollow")){ $nofollowChecked = " checked=\'checked\'";}
?>
<div id="categories-all" class="ui-tabs-panel">
<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
<li id=\'category-<?php echo $noindexCat ?>\' class="popular-category"><label class="selectit"><input value="<?php echo $noindexCat ?>" type="checkbox" name="post_category[]" id="in-category-<?php echo $noindexCat ?>"<?php echo $noindexChecked ?> /> noindex</label></li>
<li id=\'category-<?php echo $nofollowCat ?>\' class="popular-category"><label class="selectit"><input value="<?php echo $nofollowCat ?>" type="checkbox" name="post_category[]" id="in-category-<?php echo $nofollowCat ?>"<?php echo $nofollowChecked ?> /> nofollow</label></li>
<li id=\'category-1\' class="popular-category" style="display:none;"><label class="selectit"><input value="1" type="checkbox" name="post_category[]" id="in-category-1" checked="checked"/> Uncategorized</label></li>
</ul>
</div>
<?php
}
add_action(\'save_post\', \'custom_add_save\');
function custom_add_save($postID){
if (defined(\'DOING_AUTOSAVE\') && DOING_AUTOSAVE) {
return $postID;
}
else
{
// called after a post or page is saved
if($parent_id = wp_is_post_revision($postID))
{
$postID = $parent_id;
}
if ($_POST[\'cb2_customHeader\'])
{
update_custom_meta($postID, $_POST[\'cb2_customHeader\'], \'cb2_customHeader\');
}
else
{
update_custom_meta($postID, \'\', \'cb2_customHeader\');
}
if ($_POST[\'cb2_customTitle\'])
{
update_custom_meta($postID, $_POST[\'cb2_customTitle\'], \'cb2_customTitle\');
}
else
{
update_custom_meta($postID, \'\', \'cb2_customTitle\');
}
}
}
function update_custom_meta($postID, $newvalue, $field_name) {
update_post_meta($postID, $field_name, $newvalue);
}