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
2answers
331 views

WP Cron is “half-failing” to insert posts

I built a plugin for my company, which basically goes to tube sites, scrapes them for content, and posts them automatically in whatever state is defined (publish, draft, future, etc). Now, everything ...
1
vote
1answer
505 views

update_post_meta, xml parser

I'm hitting the wall for nearly two hours now, trying to figure this out. Here is the thing' I have made a xml parser to read xml file and add posts (with content) from xml: $ch = curl_init( ...
0
votes
2answers
252 views

Using wp_insert_post with WP Network in a cron script

I have network of sites, and I need to import data into them via a cron job. Obviously wp_insert_post is meaningless in this case, since i'm not in a blog...i'm in a cron script. I also read that ...
1
vote
2answers
4k views

How to use wp_insert_post to update meta box?

I'm trying to use wp_insert_post to create a front-end submission form so visitors can create a post AND update the meta box fields of that post -- not the custom fields. For example, when I use the ...
0
votes
1answer
164 views

How can I correctly redirect user to the submitted post and define a template for each new post in Wordpress?

What I want to do is to create a simple front-end post submit form, for every different type of post I will include in my Wordpress app. For example there will be articles, events, quick messages and ...
2
votes
2answers
590 views

wordpress sanitize array?

I have a custom post form that sends data to a page which uses wp_insert_post to create a post. I can easily sanitize most data, but I have some troubles with my tags, I retrieve in an array: $tags = ...
1
vote
0answers
464 views

wp_insert_post not returning post ID? [closed]

I've had a read of the existing posts on here and still can't see why my instance is doing this, but I'm using wp_insert_post to add a post with some data it's given, and it's inserting the post just ...
0
votes
1answer
298 views

Conditional wp_mail statement on post

I am currently posting from the front end using a similar model as http://voodoopress.com/2011/03/review-of-posting-from-front-end-form/. I want to send an email to certain addresses based on the ...
-2
votes
1answer
273 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 ...
1
vote
1answer
1k views

Insert post in another database

I have developed a custom script that uses wp_insert_post to create new posts, however i'd like to use similar code to create the same data in another wp database. Could be this done on the fly before ...
0
votes
2answers
2k views

how can I set the post author of a post I just created with php?

I'm using php to dynamically create a custom post, and I need the author to be someone other than the logged in user. I found this ...
0
votes
3answers
3k views

Prevent duplicate posts in wp_insert_post using custom fields

My source links are something linke this : http://sample.com/entertainment/default.aspx?tabid=2305&conid=102950 http://sample.com/entertainment/default.aspx?tabid=2418&conid=104330 ...
1
vote
2answers
1k views

What hook should be used to programmatically create a post only when master post is updated?

Pippin and Jean-Baptiste Jung have very good tutorials on how to programmatically create content when a new post is published using these four actions hooks... publish{post_type} ...
1
vote
5answers
1k views

Insert Wordpress page via external (cron) script?

I'm trying to write a php script that I can run out of cron to create new Wordpress pages. Unfortunately, I can't find any documentation on how to do this. I'm using the WP scripts rather than ...
0
votes
3answers
733 views

How to prevent duplicate posts with wp_insert_post on single.php?

I'm getting a really strange bug (WP 3.1.3). My goal is to have users create a new post simply by landing on a single post. In order to make that happen, I have the following code in my single.php: ...
5
votes
3answers
7k views

Attaching taxonomy data to post with wp_insert_post

I am implementing (trying) a front end posting system which shows taxonomy data in several dropdown select fields, each of the dropdowns is named by using the "name" $arg in wp_dropdown_categories. ...
3
votes
1answer
1k views

Does wp_insert_post validate the input?

If I use the wp_insert_post in a plugin, will I have to check the content for SQL injection problems and XSS or will the wp_insert_post function do this for me?
3
votes
1answer
944 views

Using wp_insert_post() with Networking enabled

I'm working on a script that will drop articles directly into the wordpress database, using wp_insert_posts(). However, I have networking enabled and the wp_insert_post() reference page has no ...
3
votes
2answers
439 views

wp_insert_post breaks rewrite rules

I'm using wp_insert_post to programmatically add content to a site. This works fine with posts, categories and tags, but not with pages. When I attempt to add a page (i.e. post with post_type=page), ...
2
votes
4answers
2k views

wp_set_object_terms() Fails to Set Terms

Okay guys, here's the scenario. I'm am trying to setup a function that will automatically duplicate a post (when published) over to another post type. So, a regular blog post is published, and when ...