Reputation: 1089
my wordpress blog is about musics, and everytime i post a music in my blog i follow the same routine which is very tiresome. So I want to know how can i speed up the process.
Here's my routine when I'm posting new music to my blog:
So these 3 steps are very tiring, because each time i add a new music in my blog i need to follow 3 steps. i want to know if there's a way to put all these steps in one page, this page will have input boxes for media, background post type and add new post.
Please tell me how i can do this. thank you
Upvotes: 1
Views: 546
Reputation: 498
Well, you could have a plugin, in admin panel form with fields like browse
for media, post type
, additional image browse
etc. Then have some dynamic function, which takes this form data in variable and on $_POST creates post/registers metas/media etc. using built in worpress functions.
Might also look at template feature of wordpress, might use it in plugin help with the background thing.
This is just an example of using Wordpress built in functions to create post:
<?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
}
}
?>
Upvotes: 1