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

6
votes
1answer
68 views

What is “meta_input” parameter in wp_insert_post() used for?

I am inserting some post into wordpress using the function wp_insert_post(). I want to insert some custom fields on each post and reading the documentation I though the meta_info parameter was used ...
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
0answers
26 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
2answers
21 views

Get Post ID after front end post submission

I can't get the published post ID, i'm using a front end custom form. When the submit button is clicked site is re directed to a different page. Now, i can't get the just published post ID using: ...
0
votes
1answer
27 views

Where to call wp_insert_user() and wp_insert_post() from?

I'm trying to perform a batch insertion of multiple users and posts using the wp_insert_user() and wp_insert_post() functions. The problem is, I can't find any clear instructions as to where I should ...
0
votes
2answers
25 views

oEmbded with wp_insert_post() [embedly]

I try to add articles via wp_insert_post but as it seems the oEmbed function of Wordpress doesn't work properly. I work with embedly as you can embed any website. I realized that the oEmbed ...
0
votes
0answers
31 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 ...
3
votes
1answer
51 views

See error message from wp_insert_post function?

I'm using wp_insert_post function to insert a new post: $result = wp_insert_post(array("post_title"=>"test1"), true); When I echo the result of the function, I get the number 335. How can I see ...
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
19 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 ...
1
vote
2answers
67 views

wp_insert_post creates multiple pages

I have a function in functions.php which automatically generates a page. It doesn't check to see if there is already a page with the same title at the moment. The function is started with: ...
2
votes
2answers
53 views

Automatically insert php function into post $the_content

I am trying to have 2 php functions automatically inserted in every post for my CPT. The problem I am having is that even though I've found a way to add text, Im not sure how to add the php functions ...
0
votes
0answers
33 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
21 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
37 views

tax_input not working wp_insert_post

I am using wp_insert_post and all the fields are working except tax_input is working. Is there something wrong with my code? $customtax = array( 'product_link' => $link, 'product_price' => ...
0
votes
1answer
56 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
253 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
108 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
55 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
109 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 ...
2
votes
1answer
136 views

XMLRPC Avoid duplicate content

I want to avoid duplicate post content via xmlrpc. So: if post exists nothing happens... . if does not exists data insertion occurs... . The method for checking would be post title or post ...
0
votes
1answer
40 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 ...
2
votes
2answers
46 views

Replace string with post_name on sidebar

I'd like to replace all {POST_NAME} 's from my text-widgets on single.php sidebar. I'm thinking of something like this global $post; $POST_NAME= $post->post_name; $sidebar = ...
0
votes
1answer
93 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
51 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
78 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 ...
1
vote
0answers
456 views

Issue with wp_insert_post and post_content field error Could not update post in the database

I'm having issues creating an import / caching script to be used within a WordPress site. This feed comes from a single text file that is then parsed and returned as an array. When running through ...
0
votes
1answer
186 views

duplicate entries in database while using save_post or wp_insert_post

Here is what I am trying to do - I have created a custom table in the database and I am trying to enter data into it everytime a post is created. The database-entry needs to happen ONCE AND ONLY WHEN ...
0
votes
2answers
54 views

Wordpress implode & wp_insert_post question

Just a few days ago I've started working on my new wordpress based website. I have a plugin which provides a Cars Database. I want to auto-fill my custom fields and taxonomies by taking info from ...
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
209 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
171 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 ...
1
vote
1answer
101 views

How can I stop wp_update_post messing up HTML example code?

I'm showing little pieces of example HTML/PHP code on the frontend (with syntax highlighting). The entries are displayed as FAQ custom posts, and have a plugin (CMS Tree page) to alter the menu order, ...
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 ...
1
vote
2answers
238 views

save_post action to include wp_insert_post_data filter, gathering meta field info & prevent infinite loop

Im trying to change the title of a post, but I want to include info from a meta field, the value of which isn't saved to the database until after the posts has already been saved. Other than this one ...
2
votes
1answer
135 views

Visual Editor - Colorize Shortcodes

I want to highlight shortcodes in the WordPress visual editor in a specific color. E.g. I Have the following Shortcodes [shortcode1] Some text [/shortcode1] ... [shortcode2] Some text ...
0
votes
0answers
284 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
168 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
186 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
257 views

Set default Custom Post Meta Value

I've tried almost anything and just can't get this to work. I have a custom post type with a custom meta field and I want a default value to be added on when the Publish/Update/Save button is ...
0
votes
1answer
81 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 ...
2
votes
1answer
98 views

Efficient way to save a lot of meta data

im currently developing a plugin that will read an external xml, and convert the data to a custom post type. Each post needs around 50-60 meta_fields. Right now im looping through each piece of needed ...
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
77 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 ...