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
997 views

preventing the duplicate wp_insert_post

Right of the bat, let me say that this is not the same question as I posted the other day ( that is duplicate posts when trying to update a post using the wp_insert_post. ) Cause, in that question, ...
0
votes
1answer
291 views

wp_insert_post - duration

i try to import a custom DB to the WP DB with about 2000 rows (custom post type). the problem is that the insert by wp_insert_post takes about a second per insert. Is this normal ? Is there a ...
0
votes
1answer
523 views

Deleting terms from the Wordpress wp terms table

what wp function do i use so that I can delete a term without worrying about the related tables such as wp term relationships and wp term taxonomy? Also if a post has a relationship to the deleted ...
0
votes
1answer
147 views

how to add datas in taxonomy to post with wp_insert_post

how to add datas in taxonomy to post with wp_insert_post this is my code but it is saved in my texonomy draft,why? i have given post_type=publish. $my_post = array( 'post_title' => ...
0
votes
1answer
150 views

Somehow adding to “Insert Into URL” posts are contradicting each other

I added a second upload image ( doc_thumb_box ). They both work perfectly independent of each other. But when the second one is added, the first one (doc_uri_box ) no longer pastes the value of the ...
0
votes
3answers
541 views

Trying to save custom post type from frontend partially working

I've created the following custom post type (lugares means places) with a custom taxonomy of tacos and it works fine form the backend: /** * Custom post-type lugares **/ add_action('init', ...
0
votes
2answers
502 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 ...
0
votes
2answers
318 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 ...
0
votes
1answer
278 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 ...
0
votes
1answer
345 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 ...
0
votes
3answers
1k 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: ...
0
votes
1answer
8 views

Importing custom DB table entries as posts with Categories

I'm using the following code to import all entries within a custom DB table as posts. The function fires from an init hook. All taxonomies are created, and all entries from the DB are imported, ...
0
votes
0answers
25 views

Getting blank (no title) posts submitted when using wp_insert_post()

I have users submitting post to the wordpress admin. For the most part this works but sometimes I will get post submitted that are blank and (no title) is the title. I cant seem to find out why this ...
0
votes
1answer
34 views

Update post meta does not serialize array

For some reason my update_post_meta() function does not accept an array. Normally the function serializes the array by itself, but now I need to do this by myself, otherwise it does not update. Could ...
0
votes
0answers
32 views

Using wp_insert_post() and wp_insert_attachment() at the same time

I am working on migrate blog posts, which are more than 1000 posts, from an old custom database website to wordpress. After formatted each post with php array, I am testing how to migrate them to ...
0
votes
1answer
27 views

Getting duplicate page when activating my plugin

I am creating a plugin in which I need to create a dynamic page and assign a template to it. I have created it using the code below: function gallerypage() { global $wpdb; $check_page = ...
0
votes
2answers
20 views

PHP - Multiple variables in insert post array

I am currently creating a post programmatically, with the wp_insert_post function but am having some difficulties when adding two variables into the content part of the array. I would like to add ...
0
votes
0answers
34 views

Use return values on AJAX call to async-upload.php via Add Media

I noticed, every time I upload images via Add Media button on front-end. It makes AJAX request to async-upload.php and returns attachment file information. On above image, I have 3 images uploaded ...
0
votes
0answers
22 views

How to update post_parent on images uploaded via Add Media button from front-end

I'm working on a plugin that will allow registered users to post content from front-end. I added WordPress default Add Media button on TinyMCE and noticed all the images uploaded via Add Media get ...
0
votes
1answer
57 views

Create Post Using Form on WP Dashboard

As always, I have unique situations and client requests. I am working on a custom dashboard widget that will include a form to register for an event. Once the form is submitted, it will generate a ...
0
votes
0answers
257 views

Upload featured image from front end using media-upload.php

I'm trying to use admin/upload.php to upload featured image from front end form. All I have to do is put below code in the front end form <div id="postimagediv" class="postbox "> <div ...
0
votes
1answer
111 views

How to handle dynamic form data with repeating fields?

I'm attempting to create a form with duplicatable sections for a listing site. It should work like this: Start with one listing form -> Fill out the form Click "add another" and another duplicate ...
0
votes
0answers
56 views

How to add featured image on front end form?

I'm working on my first WordPress plug-in for front end posting where signed in users can post and manage their articles on front end. I'm pretty close to be done but can't find a way to add Featured ...
0
votes
1answer
112 views

wp_insert_post() post_author and return post_id are not working

This is my first time creating a plugin for WordPress and I'm trying to create a plugin for Front-end form for logged in users. So far, the front-end form shows up on a page with a shortcode ...
0
votes
1answer
41 views

Wrote a WP Cron Plugin and it triggers a fatal error upon activation

I'm writing a WP Plugin for one of my sites that hooks into a public API to get app data and save that within Wordpress to allow for WP to be able to search & filter the data based on new ...
0
votes
1answer
94 views

Update post_meta post_name with the post ID from wp_insert_post after user register

I'm creating a function that creates a page for a user when they register. The post created sits within a certain category. These are standard posts NOT custom post types. After the post is created I ...
0
votes
0answers
72 views

wp_insert_term or wp_set_object_terms not working in register_activation_hook?

I am creating a couple of CPTs and assigning a term to these posts. The posts are being created properly, but the term isn't being assigned to the posts. I tried using tax_input, wp_set_object_terms. ...
0
votes
1answer
52 views

Front end post submissions do not get submitted in the category

If I submit the post after choosing a category the post doesnt get submitted and instead it takes me to the category page i have selected.However if i delete the fieldset "category" and fill the form ...
0
votes
0answers
79 views

How to update posts via PHP in wordpress

I need to do the exact same what "update" button in the WP Backend does, but with PHP (and I know it has been asked 10'000 times, but the situation isn't that trivial :( ) wp_update_post should be ...
0
votes
0answers
42 views

Setting title in the front end

I am trying to set up posting from the front end. Everything works, but I cannot get the title to set.. Part of code: (Some validation is done beforehand) $title = "abc"; // ADD THE FORM INPUT ...
0
votes
2answers
215 views

generate unique slug while inserting post

How can i create unique slug while inserting a new post.. I know i can query posts and compare the records to create unique slug but I want to insert a post with unique slug at the same time. Lets ...
0
votes
1answer
173 views

Can't get post ID using wp_insert_post_data

I have 3 custom fields as shown below. I want to use them to generate the title when I save/publish... etc The code works if I insert the post id as a number but not like this... function ...
0
votes
1answer
49 views

Generate slug and meta data if meta field is empty

I am creating a current vacancies feature in a client site, and am struggling on one area. I want to have a slug generated from a reference number, rather than the post title. This, I have set up. ...
0
votes
0answers
89 views

wp_update_post adding a -2 to the post slug

I've recently created a php file that is creating posts using the wp_insert_post function. This is working great and its inserting the post as it should do. I am leaving out the post title as I want ...
0
votes
1answer
131 views

Bulk insert posts is really slow and skips entries

I'm writing a plugin to parse a bunch of XML files with the NewsML standard and insert them into the database as custom post type. Everything works fine and as intended, but especially at the first ...
0
votes
0answers
287 views

Check if Post Id exists, Insert post if doesn't, and update meta status 0 if does

I was looking for an answer and found this example: $postTitle = $_POST['post_title']; $submit = $_POST['submit']; if(isset($submit)){ global $user_ID, $wpdb; $query = $wpdb->prepare( ...
0
votes
1answer
46 views

Add a image to a post published on a CPT from the front-end

I created a CPT with a page where you can add posts from the Frontend. This is the code in the fuction.php: // Hook into the 'init' action add_action( 'init', 'register_cpt_promociona', 0 ); if ( ! ...
0
votes
1answer
107 views

Pay before posting (frontend insert post)

I have a form on the frontend which I want users to fill out, when they have I want to save the data and redirect them to pay before submitting the post. How do I save the data before they pay? I ...
0
votes
0answers
171 views

How to retrieve data sent via wp_remote_post() from another WordPress site?

So, I am using wp_remote_post() on site A to send data to my server B, then use this data to create a new blog post each time request is sent. Here is the scenario: 1- Site A: send data via ...
0
votes
0answers
22 views

How to pick up featured image from set of pictures

I'm trying to create front end form for posting. The following questions are concerning me so bad. How can I set a featured image? I tried set_post_thumbnail($pid, $newuploadid); but nothing happend. ...
0
votes
1answer
187 views

Insert attachments from front end form

I built a front end form but suddenly cannot submit my image attachments. Refer to these articles which do not get it done: ...
0
votes
1answer
83 views

Manually insert post into MULTISITE database: Need to specify the TABLE

I need to manually insert a post into multisite database. I'm using the variables listed here: http://codex.wordpress.org/Function_Reference/wp_insert_post ...and have been able to insert a post into ...
0
votes
0answers
84 views

Insert post programmatically and decide to tweet or not to tweet

I am inserting a new post using wp_insert_post() and want to be able to decide if this post gets tweeted or not using the WP to Twitter plugin. First, I create the post, like so: $newpost = array( ...
0
votes
0answers
78 views

Update post else insert post

I'm trying to insert posts from a CSV. This is all working fine, and also meta boxes are getting inserted. But the update functionality isn't working, and I just can't seem to get it right. I know I ...
0
votes
0answers
23 views

Insert post from front end, need to update it for it to show on page

I have this form and in my functions I do a wp_insert_post where I insert the form values into custom fields on my custom post type. Everything is working fine, the post is Published and all the data ...
0
votes
1answer
164 views

wp_insert_post with advanced custum fields repeater

at the moment i stuck a little bit at my new wordpress project. The basics are: The user can create nutrition plans and there he can add some recipes, so i need to build a relationship from user > ...
0
votes
1answer
235 views

Problem on wpdb queries, wp_insert_post, wp_insert_user etc. The query runs twice

Anyone encountered this issue? I have created a custom php script which adds a new post by using wp_insert_post() but everytime I run the code it creates a 2 new post where in it should be only be ...
0
votes
0answers
73 views

wordpress form processing to custom post type not working

I'm trying to insert a custom post type for a multiple image upload form. The below code is the form processing. The page is blank when i submit the form. Where did i go wrong? <?php ...
0
votes
1answer
232 views

php wp_insert data on front using a form

I'm using a form on my website to allow user to create posts on my wordpress admin. It works fine, but I have an issue, I don't get the tags meta inside my admin. here is my php code : <?php ...
0
votes
1answer
84 views

Add image to post from external URL

I'm doing a plugin that can retrieve media from external APIs, and when I click on it (on the admin), it insert a new post with the media, its caption, etc. So, now, I'm inserting a new post on click ...