This function inserts posts (and pages) into 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 an error).

learn more… | top users | synonyms

0
votes
1answer
145 views

wordpress apply filters and is singular()

I'd like to know whether anybody has heard of , or created a workaround to the following problem: let's say there is a plugin which has code like this, add_filter('the_content'.'some_func'); ...
0
votes
1answer
667 views

Inserting post_id into guid before wp_insert_post

I would like to insert data into the wp_posts table with the inserted post_id in the 'guid' for a record that doesn't already exist. Below is the closest I've gotten but this doesn't work ...
0
votes
1answer
858 views

How to update post parent?

I have an array of image id's and i want assign them to the specific post: foreach ($image_ids as $image_id) var_dump(wp_insert_post(array('ID' => $image_id, 'post_parent' => ...
0
votes
2answers
205 views

Upload image and assign it's id to post

At the moment i am working on database conversation script from other cms to Wordpress and faced one problem: I have a list of images, so i need to upload it to Wordpress, after it receive new link, ...
0
votes
1answer
186 views

Insert new post for each user infinite loop error

I wrote this little function to automatically create a post for every user of the blog but it creates an infinite loop (I disabled it to stop it creating new posts). I'm not very skilled in php, I ...
0
votes
1answer
918 views

wp_insert_post does not write my post_name

i tried to generate a page via wp_insert_post. That works fine except that the post_name is always written with the same value as the post_title. Here comes the code snippet: // Create homesite if ...
0
votes
1answer
226 views

Fire a hook programmatically

Is it possible to fire a wordpress hook programmatically? Specifically I'd like to have control of wp-insert-post.
0
votes
1answer
1k views

wp_insert_post with POST data

I found some code on this site for wp_insert_post and I got it working. I did find the post in the category where I would expect it to be. Then I changed the code example to include information from ...
0
votes
1answer
1k views

Cant get front end form to post to wordpress

Long time lurker, first time poster, and big time PHP noob. Apologies if my question is a little vague, but i have the code below and I know im doing some sort of schoolboy error but it just wont ...
0
votes
1answer
190 views

Is this the correct way to add post-slug input field?

I added slug input field in my custom post type and allow users to edit it at front end. Then, when insert post, I use this: $wp_insert_post_args = array( 'post_status' => 'publish', ...
0
votes
2answers
40 views

upload images on front by user using form

I'm using a form on my website using wordpress to allow users to create posts. It works perfectly fine, I'm abble to assign the posts to a custom post type, add Advanced Custom Fields, content, ...
-1
votes
1answer
119 views

The reverse of wp_insert_post

When you need to delete a post programmatically what wp function do you use so that if takes care of the wp_term_relations too?
-1
votes
3answers
141 views

Programatically add a page in Wordpress

I am trying to add a page to WordPress programatically. I am using this code: function add_media_page(){ if(!(is_page('My New Post'))){ // Create post object $my_post = array( 'post_title' ...
-1
votes
1answer
108 views

Use of wp_insert_post and parameters

I've JUST started using WordPress..i'm trying to add posts to Wordpress using php and i came across this piece of code: // Create post object $my_post = array( 'post_title' => 'My post', ...
-1
votes
1answer
579 views

How to insert category and subcategory using 'wp_insert_post' function?

How would be the array, to insert a post category and subcategory? Thanks.
-2
votes
1answer
290 views

wp_insert_post() dont post content like i need it :(

my wordpress instalation have a plugin that "probably" use wp_insert_post() to send content to database. works great. but sometime when i edit the POST with the tinyMCE editor, the editor do the ...