2012年2月22日 星期三

自訂義英文標題欄位在編輯文章時出現

//找到佈景裡的function.php
//加上底下

//Custom EnglishTitle Widget
add_action('admin_menu', 'custom_EnTitle_hooks');
add_action('save_post', 'save_custom_EnTitle');
add_action('wp_head','insert_custom_EnTitle');
function custom_EnTitle_hooks() {
  add_meta_box('custom_EnTitle', '自訂英文標題', 'custom_EnTitle_input', 'post', 'normal', 'high');
  add_meta_box('custom_EnTitle', '自訂英文標題', 'custom_EnTitle_input', 'page', 'normal', 'high');
}
function custom_EnTitle_input() {
  global $post;
  echo '';
  echo '';
}
function save_custom_EnTitle($post_id) {
  if (!wp_verify_nonce($_POST['custom_EnTitle_noncename'], 'custom-EnTitle')) return $post_id;
  if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return $post_id;
  $custom_EnTitle = $_POST['custom_EnTitle'];
  update_post_meta($post_id, '_custom_EnTitle', $custom_EnTitle);
}
function insert_custom_EnTitle() {
  if (is_page() || is_single()) {
    if (have_posts()) : while (have_posts()) : the_post();
      endwhile; endif;
      rewind_posts();
  }
}

//在要使用的地方加上

沒有留言:

張貼留言