How to combine multiple wp_insert_post into one in order to gain better performance

I would advise using wp_insert_post() and putting you text files into a CSV CSV Post Title,Post Content, “title”, “content”, “title”, “content”… PHP $path = “/posts.csv”; //require __DIR__ . “$path”; $file = fopen(__DIR__ . $path, ‘r’); while (($line = fgetcsv($file)) !== FALSE) { //$line is an array of the csv elements $post[“id”] = wp_insert_post( array( “post_title” … Read more

Why cant I add a custom post type to a custom taxonomy?

The post_category you are using is for core categories taxonomy. For custom taxonomies you have to use tax_input. For example, the next code set terms for custom_tax_category and custom_ta_tag taxonomies. $args = array( ‘post_type’ => ‘custom_post_type’, ‘post_title’ => wp_strip_all_tags( $title ), ‘post_content’ => ‘some content’, ‘post_status’ => ‘publish’, ‘post_author’ => $author_id, ‘tax_input’ => array( ‘custom_tax_category’ … Read more

Add file while inserting post

You can attach images to a post from URI via the media_sideload_image function: $post = array(); // your post data $post_id = wp_insert_post( $post ); $url = “http://s.wordpress.org/style/images/wp3-logo.png”; $desc = “The WordPress Logo”; $image = media_sideload_image( $url, $post_id, $desc );

Creating a post from data returned from HTML form

I worked it out and re-wrote the code: jQuery(document).ready(function() { jQuery(‘#createacostume’).submit(function( event ) { event.preventDefault(); var aForm = jQuery(this); var bForm = aForm.serializeArray(); bForm.push({name: ‘action’, value: ‘myAjaxFunction’}); jQuery.ajax({ url: ajaxurl, type: “POST”, data: bForm, success: function(resp) { alert(“Thank you for your post. We will review it and approve it shortly” + resp); }, error: function( … Read more

Use of wp_insert_post and parameters

Check the docs at http://codex.wordpress.org/Function_Reference/wp_insert_post for the parameters to use with wp_insert_post This function inserts posts (and pages) in the database. It sanitizes variables, does some checks, fills in missing variables like date/time, etc. It takes an array as its argument and returns the post ID of the created post (or 0 if there is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)