2012-02-22 23 views
-1

私の最初の大きなプロジェクトのようなテーマを初めて開発しています。私は私のfunctions.phpに書きました空白のpost.phpとWordPressのカスタムポストタイプ3 submit

すべてがスムーズに行きました。私はBands Gigs用のカスタムポストタイプに3つのカスタムメタボックスを持っています。

メタボックスは、Gig Venue、Gig Country、Gig Dateです。

管理パネルにすべてが表示されます。新しいギグを追加するには、すべての情報を入力します。しかし、いったん公開すると、/wp-admin/post.phpにリダイレクトされ、完全に空白になります。

urlバーからpost.phpを削除するだけで、管理パネルに戻ってきて、ギグが投稿され、バンドギグのメインリストに表示されます。

新しいカスタムポストタイプの場合だけでなく、新しいページを追加する場合もあります。このテーマでは必要ないので、私は管理パネルからPOSTS、MEDIA、LINKSメニュー項目を隠す機能を書いていました。

誰かがこの問題を抱えていますが、私が考え出していない簡単な修正がありますか?

私が試したこと: - テーマを削除して、再インストールしてください。 - データベースのDBと新規インストールを削除しました - テーマフォルダにテーマが既にアップロードされている状態で、WP alltogetherを新規インストールで削除しました。

まだ何もありません。

すべてのヘルプ、または正しい方向を指している指がすばらしいでしょう。ここのPHPとしてNooby。

ここには私が書いたfunctions.phpコードがいくつかのチュートリアルのオンラインに続いてあります。

<?php 

// remove menu items that are not needed for this specific theme 
function remove_menus() { 
global $menu; 
     $restricted = array(
       __('Posts'), 
       __('Media'), 
       __('Links'), 
       __('Comments'), 
     ); 

     end ($menu); 
     while (prev($menu)){ 
      $value = explode(' ',$menu[key($menu)][0]); 
      if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);} 
     } 
} 
add_action('admin_menu', 'remove_menus'); 



// create custom post type for GIGS 
add_action('init', 'gig_register'); 

function gig_register() { 

    $labels = array(
     'name' => _x('Band Gigs', 'post type general name'), 
     'singular_name' => _x('Band Gig', 'post type singular name'), 
     'add_new' => _x('Add New Gig', 'show date'), 
     'add_new_item' => __('Add New Gig Date'), 
     'edit_item' => __('Edit Gig Date'), 
     'new_item' => __('New Gig Date'), 
     'view_item' => __('View Gig Date'), 
     'search_items' => __('Search Gigs'), 
     'not_found' => __('Nothing found'), 
     'not_found_in_trash' => __('Nothing found in Trash'), 
     'parent_item_colon' => '', 
    ); 

    $args = array(
     'labels' => $labels, 
     'public' => true, 
     'publicly_queryable' => true, 
     'show_ui' => true, 
     'query_var' => true, 
     'menu_icon' => get_stylesheet_directory_uri() . '/images/calendar_pencil.png', 
     'rewrite' => true, 
     'capability_type' => 'post', 
     'hierarchical' => false, 
     'menu_position' => null, 
     'supports' => array(
      'custom-fields' => true, 
     ), 
    ); 

    register_post_type('gigs' , $args); 
} 



// create custom meta boxes for show dates/locations 
add_action("admin_init", "admin_init"); 

function admin_init() { 
    add_meta_box("gig_venue_meta", "Gig Venue", "gig_venue", "gigs", "normal", "low"); 
    add_meta_box("gig_country_meta", "Gig Country", "gig_country", "gigs", "normal", "low"); 
    add_meta_box("gig_time_meta", "Gig Date || Date format must be M,D,Y (ex: 5/12/2012)", "gig_date", "gigs", "normal", "low"); 
} 



// create inputs for custom meta boxes 
function gig_venue(){ 
    global $post; 
    $custom = get_post_custom($post->ID); 
    $gig_venue = $custom["gig_venue"][0]; 
    ?> 
    <label>Venue Name:</label> 
    <input name="gig_venue" value="<?php echo $gig_venue; ?>" placeholder="Enter Venue Name Here" /> 
    <?php 
} 

function gig_country(){ 
    global $post; 
    $custom = get_post_custom($post->ID); 
    $gig_country = $custom["gig_country"][0]; 
    ?> 
    <label>Gig Country:</label> 
    <input name="gig_country" value="<?php echo $gig_country; ?>" placeholder="Enter Country Here" /> 
    <?php 
} 

function gig_date(){ 
    global $post; 
    $custom = get_post_custom($post->ID); 
    $gig_date = $custom["gig_date"][0]; 
    ?> 
    <label>Gig Time:</label> 
    <input name="gig_date" value="<?php echo $gig_date; ?>" placeholder="Enter Gig Date Here" /> 
    <?php 
} 
// end creation of inputs for custom meta boxes 


// save custom meta boxes info 
add_action('save_post', 'save_details'); 

function save_details(){ 
    global $post; 

    update_post_meta($post->ID, "gig_venue", $_POST["gig_venue"]); 
    update_post_meta($post->ID, "gig_country", $_POST["gig_country"]); 
    update_post_meta($post->ID, "gig_date", $_POST["gig_date"]); 
} 
// end save custom meta box info 


// edit gig page list info 
add_action("manage_posts_custom_column", "gigs_custom_columns"); 
add_filter("manage_edit-gigs_columns", "gigs_edit_columns"); 

function gigs_edit_columns($columns) { 
    $columns = array(
      "cb" => "<input type=\"checkbox\" />", 
      "gig_venue" => "Gig Venue", 
      "gig_country" => "Gig Country", 
      "gig_date" => "Gig Date", 
    ); 

    return $columns; 
} 

function gigs_custom_columns($columns) { 
    global $post; 

    switch ($columns) { 
     case "gig_venue": 
      $custom = get_post_custom(); 
      echo $custom["gig_venue"][0]; 
      break; 
     case "gig_country": 
      $custom = get_post_custom(); 
      echo $custom["gig_country"][0]; 
      break; 
     case "gig_date": 
      $custom = get_post_custom(); 
      echo $custom["gig_date"][0]; 
      break; 
    } 
} 
// end edit gig page list info 



?> 
+0

うーん、「ポスト」ボタンを素早くビットを打ったかもしれないこと、しかし、あなたは、問題が起こった前に働いていた任意のコードを投稿できる方法はありますか? – summea

+0

申し訳ありませんが、残りの質問を投稿する前に投稿ボタンを押しました。 –

+0

ああ、私のDOCTYPEについて何も書かれていないこれらの4つの空白行を取得しています。添付された画像です。 http://cl.ly/063Z020b0b1l42170l3l –

答えて

0

function.phpの最後の行に>?削除し、それがうまくいきます! origanl twentyeleven function.phpを見てください。ファイルの最後にphpクローズタグはありません。

さようなら

関連する問題