2011-12-20 35 views
1

我的博客是關於音樂的,每次我在我的博客上發佈音樂時,我都會遵循同樣的程序,這非常令人厭煩。所以我想知道如何加快這個過程。如何在Wordpress中製作自定義文章界面?

這裏是我的家常便飯,當我發佈新的音樂,我的博客:

  1. 轉至媒體和上傳新的圖片爲新的音樂。
  2. 轉到背景帖子類型,併爲新音樂創建新的背景帖子類型。
  3. 前往帖子 - >添加新的並附加以前創建的背景帖子類型和圖片到這個帖子,並在輸入這個新音樂的詳細信息後發佈帖子。

因此,這3個步驟是非常累人的,因爲每次我在我的博客中添加一個新的音樂,我需要遵循3個步驟。我想知道是否有一種方法可以將所有這些步驟放在一個頁面中,該頁面將具有媒體輸入框,後臺帖子類型和添加新帖子。

請告訴我我該如何做到這一點。謝謝

回答

1

好了,你可以有一個插件,在管理面板形式像browse媒體,post type,附加圖像browse等領域然後有一些動態的功能,這需要在變量和$此表數據_POST使用內置的worpress功能創建帖子/寄存器元數據/媒體等。

不妨看看wordpress的模板功能,可能會在插件幫助中使用它和背景有關。

這僅僅是使用WordPress內置函數創建後一個例如:

<?php 
function create_posts_from_serialized_array() { 

//Inyour case it will be $_POST not these two lines 
$dude_wheresmyarray = 'LOCATION OF YOUR UNSERIALISED ARRAY'; //Dude, where's my array? 
$original_array = unserialize (file_get_contents($dude_wheresmyarray));  // Load array 

// Create categories, return variables containg newly created category ids 

$category = array('cat_ID' => '', 'cat_name'=> utf8_encode('Cat1'), 'category_description' => '', 'category_nicename' => 'cat1', 'category_parent' => '');   $cat_id10 = wp_insert_category($category, true); 

$aid = 0; //foreach array begin with 0 and ++ later on 

foreach ($original_array as $each_array) { 

/* 
* Variable for new post on left, variable from $original_array on right 
*/ 
$new_post_title = $original_array[$aid]['title']; 
$new_post_content = $original_array[$aid]['description']; 
$new_category = $original_array[$aid]['category']; 
$new_name = $original_array[$aid]['name']; 
$new_address = $original_array[$aid]['address']; 
$new_phone = $original_array[$aid]['phone']; 
$new_web = $original_array[$aid]['web']; 
$new_mail = $original_array[$aid]['mail']; 

if ($new_category == 'a') {$assign_cat = $cat_id1;} 

/* 
* UPDATE POST 
*/ 

$my_post = array(); 
$my_post['ID'] = ''; // Integer here WORKS ONLY IF THERE ALREADY IS A POST WITH THAT ID! 
$my_post['post_type']  = 'post'; 
$my_post['post_title']  = utf8_encode($new_post_title); 
$my_post['post_content'] = utf8_encode($new_post_content); 
$my_post['post_status'] = 'publish'; 
$my_post['post_author'] = 1; 
$my_post['post_category'] = array($assign_cat); 

$pid = wp_update_post($my_post); //Update post, return new post ID 

/* 
* UPDATE META 
*/ 

update_post_meta($pid, 'name',  utf8_encode($new_name)); 
update_post_meta($pid, 'address', utf8_encode($new_address)); 
update_post_meta($pid, 'phone',  $new_phone); 
update_post_meta($pid, 'web',  $new_web); 
update_post_meta($pid, 'mail',  $new_mail); 

$aid ++; //loopidy loopin 

} 
} 

?> 
+0

感謝。生病了看。 –

相關問題