Pre insert data when adding new custom post fire a json error
You should use content_save_pre filter. And maybe try some “simple” content first. wp_insert_post_data is fired in a lot of situations 🙂 Even at deleting.
You should use content_save_pre filter. And maybe try some “simple” content first. wp_insert_post_data is fired in a lot of situations 🙂 Even at deleting.
Turns out that the language relationship is simple and set in just a few functions: // Insert the EN post which returns the EN post id. $post_data_en = array( // add EN post data like the title and content ) $post_id_en = wp_insert_post($post_data_en, true); // Then set the language of the post pll_set_post_language($post_id_en, ‘en’); // … Read more
try putting your script in a function and running it during an action hook. perhaps the wp_footer hook.
You could avoid SQL altogether and use the XML-RPC API. This would also let you post to remote wordpress installs too. ( note if XML-RPC is not an option, scroll further down ) If Using XML-RPC Here’s some code from a quick google search using XML-RPC to post to a remote WordPress blog: http://en.forums.wordpress.com/topic/great-code-for-remote-posting?replies=5 Here’s … Read more
Maybe if you use add_post_meta instead, because update_post_meta assumes that you have already that value and you are updating it ( from http://codex.wordpress.org/Function_Reference/update_post_meta ). Also check if $doc->prod[$i]->awImage is actually a string (do print_r instead of echo).
Permalink Error I thought I was using a basic permalink, but forgot that I had used a custom permalink structure on this particular website. The custom permalink I used was %postname%. I switched it to the month and name option and now everything works. Sorry for the bogus question.
In the success part of your code, you can build an array representing a post, and use wp_insert_post as such : Example $mypost = array( ‘post_title’ => ‘My Title’, ‘post_type’ => ‘page’ //… add other fields according to your form ); $mypost_id = wp_insert_post( $mypost ); //Returns new post id on success Any field you … Read more
While the code does check for duplicates, the schema itself won’t allow it because the term_relationships table has a PRIMARY KEY of (object_id,term_taxonomy_id).
quite easily. deactivate WordPress SEO Plugin by Yoast before you playing around with the wp_insert_post function. It delays the function about a factor of hundred.
In reading through the function, I do not see anything that inherently transforms it. I’m relatively certain that there are no transforms (except maybe autop) until the display of the data. I would recommend trying one or two posts, making sure that it’s going to insert correctly, and then going all out. Also, depending on … Read more