Questions tagged [wp-insert-post]

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).

Filter by
Sorted by
Tagged with
0
votes
1answer
221 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
3k 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 ($postarr['...
0
votes
2answers
457 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
542 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
568 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
2k 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
2k 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
308 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
525 views

wp_insert_post() get Fatal Error from Plugin

I'm realizing a sort of "page" inside admin area to insert post manually without the default method. This is only the begin... Anyway, after firing Insert button of the form, the article is inserted, ...
0
votes
1answer
804 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, tags......
0
votes
2answers
5k views

wp_insert_post not working for custom post type?

For whatever reason wp_insert_post doesn't work for a custom post type. Here's the code snippet I'm using. $new_post = array( 'post_type' => 'rsp_synonym', 'post_title' => ...
-1
votes
1answer
188 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
148 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
2answers
41 views

Create a new page on front page for logged in user

I am going to find a way for logged in users to create pages from front page. For example there are three buttons so called button1,2,3. When logged in users clicks on button1, a page with title ...
-1
votes
1answer
1k views

Using wp_insert_post to create custom posts with ACF image field

I've been searching for an answer for days now. I have a project where I need to create a front-end form that will request a bunch of information and use it to create a post draft for the client to ...
-2
votes
1answer
335 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 ...
-2
votes
1answer
46 views

Is there any point to using wp_unique_post_slug?

From what I can tell, wp_insert_post will automatically append a -# to your post slug. So why does wp_unique_post_slug exist? Is it just there for legacy purposes or is there still a good reason to ...