php - How do I make a custom post interface in Wordpress?

Solution:
Well, you could have a plugin, in admin panel form with fields likebrowse
for media,post type
, additional imagebrowse
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
}
}
?>
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: installation failed, reverting ./composer.json and ./composer.lock to their original content
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.