The wp-insert-post tag has no wiki summary.
0
votes
1answer
21 views
front end posting
this source works with upload image, if without image upload, it works but 'redirect' doesn't work. what should I do?? Please let me know..
many thanks!
if( 'POST' == $_SERVER['REQUEST_METHOD'] ...
0
votes
1answer
25 views
Front end posting, not working wp_redirect with 'cannot modify header information' error
Im trying to make front end posting page but,
sometime 'wp_redirect' is not working with 'cannot modify header information' error.
adding data is working well but I don't know why is working well ...
0
votes
1answer
37 views
Plugin to create Posts and Forums then choose category and parent forum
I need to create a plugin for a customer that will help him create posts and forums and place them in a category and choose if it's a parent or a child forum.
Just created a GitHub Repo for my files ...
3
votes
3answers
132 views
Running WP Cron on specific local time
The scenario is to run insert_post function every midnight (00:00) of local time. Must run daily on weekday.
function add_daily_task(){
if((date('l', time()) != 'Saturday') || (date('l', time()) ...
0
votes
1answer
11 views
install.php Custom Taxonomy Term not being added to custom post
So I am stuck on this problem that I am facing when creating a custom taxonomy term in a install.php file.
So I am running a WP multisite, and upon new blog creations, I am trying to auto create ...
0
votes
0answers
22 views
How do I pass an array as an argument to a WP-CLI command?
I want to use WP-CLI to create some new posts with custom taxonomy terms assigned. The challenge is that wp_insert_post's tax_input argument only accepts arrays, which I would have to specify on the ...
0
votes
2answers
45 views
Faster way to wp_insert_post & add_post_meta in bulk
I have a csv file that I want to insert that consists of ~1,500 rows and 97 columns. It takes about 2-3 hours to do a full import and I'd like to improve this if there is a way. Currently for each ...
0
votes
1answer
140 views
Programmatically adding posts
I'm about to create parser which would be inserting new custom posts.
So, it's pretty simple
global $user_ID;
$new_post = array(
'post_title' => 'My New Post',
'post_content' => 'Lorem ...
0
votes
2answers
432 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 ...
1
vote
1answer
31 views
Add CPT values to Database
I am not sure if this is something easy. I have a plugin with all the functionality needed for a custom post type: Filters, navegation...
I need to create a lot of posts (with taxonomies) of this CPT ...
0
votes
1answer
247 views
Organizing uploaded media with wp_insert_post() and wp_handle_upload according to time parameter
I'm retroactively creating a post with wp_insert_post() and attaching a featuring image to it. I need the image to go into the folder that corresponds to the post's publishing date.
I'm using time ...
0
votes
1answer
50 views
How to set featured image to custom post from outside programmatically
I am trying to fetch and insert images outside the wordpress environment to a custom post via PHP.
How to move/upload that image to wordpress upload directory year date folder format just like ...
0
votes
1answer
31 views
HTML Entities in Post Title
I'm inserting posts into wordpress using a script which is loaded through CRON. Before inserting each post I am checking whether the post with the same title exists or not. Below is the snippet I'm ...
4
votes
3answers
10k views
How do I set a featured image (thumbnail) by image URL when using wp_insert_post()?
While looking through the function reference entry for wp_insert_post(), I noticed that there's no parameter in the array it requires which will allow me to set the 'Featured Image' for a post, ...
0
votes
1answer
369 views
How to prevent duplicate slugs for wp_insert_post?
I have a function that creates a page when I create a post (so as to construct parent-child relationship trees).
I'm using the $title of the post to create the page and this also creates a duplicate ...
1
vote
1answer
29 views
wp_insert_post not updating custom taxonomy selected if logged in as a subscriber
Here is my Code, it works fine When i try to post data from front end if Logged in as admin, but if i logged in as a subscriber code works fine but it is not inserting the taxonomy term i select, here ...
0
votes
1answer
36 views
Post content not showing some content
I'm inserting posts by wp_insert_post function. It works like first a post is created to get its id then an image is attached to that post id. I attach images by media sideload function. Here is the ...
0
votes
0answers
48 views
Script timeout when importing/inserting > 45-50 posts from an external table
Wondering if anyone can spot the obvious mistake or give me some guidance on where I'm going wrong.
I should also state this is my first plugin with Wordpress, so I'm sure I have overlooked ...
0
votes
0answers
49 views
Omitted Content After Post-Publish Insertion
I have a string that contains $thehtml but whenever I insert it manually into a custom post it appears that wordpress alters/strips down the html.... I've already tested/outputted $thehtml string in a ...
1
vote
1answer
586 views
wp_insert_post or wp_set_post_terms do not save taxonomy, but wp_set_post_terms does
I have a litlle problem. I have a custom taxonomy 'rodzaj' with value i.ex. obrazek. I use this code to add post:
$postArray = array(
'post_status' => 'publish',
...
0
votes
2answers
1k views
Check if Post Title exists, Insert post if doesn't, Add Incremental # to Meta if does
I already have a function where a user submits a form and creates a custom post...
<?php $postTitle = $_POST['post_title'];
$submit = $_POST['submit'];
if(isset($submit)){
global $user_ID;
...
1
vote
2answers
65 views
Adding post thumbnail in programatically inserted post
I want to insert post programatically so here is the code to add one:
global $user_ID;
$new_post = array(
'post_title' => 'My New Post',
'post_content' => 'Lorem ipsum dolor sit ...
0
votes
1answer
31 views
How To Disable Comments On New Page
I am writing a plugin that upon activation, it creates a few new pages. On these pages, I want to disable the comments option. I am adding the new pages via the code below:
$page['post_type'] = ...
0
votes
2answers
36 views
Add Page With Parent ID
I am writing a plugin that upon activation creates a set of pages. The first page that I create I want to be the parent of the rest of the pages that are added. For some reason, this is not working. ...
0
votes
1answer
71 views
Import Dummy Content and Post Thumbnails
I am setting up a small dummy content plugin. What I would like to do is import several posts using wp_insert_post. Then I would like to import several images using wp_insert_attachment and then ...
0
votes
2answers
94 views
Yet another wp_insert_post infinite loop. What is wrong?
I am writing a plugin that enables subscribed users to submit posts of a custom type, and I am trying to implement this feature via shortcodes. Now the problem is that instead of inserting one post, ...
0
votes
1answer
76 views
Alternative to new_to_publish Hook for Custom Statuses
I am looking for the right hook to use for sending out an email notice when a post is inserted. However, I am using custom statuses (in this case 'holding') which doesn't seem to get hit with the ...
0
votes
0answers
82 views
Front end Form submission
I am using the front end form to insert the posts. The code i am using is
if( 'POST' == $_SERVER['REQUEST_METHOD' ] && !empty( $_POST['action' ] ) && $_POST['action' ] == ...
0
votes
0answers
34 views
How to change all titles of a specific category?
I want to change all titles of posts from a specific category to a static one and don't want to change the rest.
I have tried this code (based on this question but it doesn't work:
...
0
votes
0answers
123 views
Insert post from frontend form
I am trying to insert post from frontend form i have different fields and i also want to upload an image. But the problem is that all othere data store except image so here is my code
if( 'POST' == ...
1
vote
1answer
140 views
post_content sanitization / transformation process
What kind of transformation does the post_content go thru when wp_insert_post inserts a post_content into wp_posts programmatically?
I'd like to be aware of this before I process 50000 recs into ...
1
vote
1answer
297 views
insert post & Upload post thumbnail from the front end using ajax
i have searched & searched for an explenation and have found some answers
that seem to be working for other people on this topics but i havent been able to get working.
This is my "form"
<div ...
0
votes
1answer
63 views
wp_insert_post memory consumption
I'm using wp_insert_post in a loop to insert 500 posts in a new WP install. It works quickly, and memory usage is from 25M to 28M. The next run of a second batch of 500 posts, takes the memory from ...
1
vote
1answer
64 views
Inserting post, thumnail and custom fields with wp_insert_post
I just want to add custom post, a thumbnail of it and custom fields.
Here is my code what I am try is to add post, thumbnail and one custom field. But I not getting the idea how to upload the ...
2
votes
1answer
206 views
Inserting Hundreds of Thousands of Posts at Once
I have a project in which I create an array of 200k+ lines w/ 25 fields that run the wp_insert_post and update_post_meta. To start it processes pretty fast the slows down a lot after 10k records or ...
2
votes
1answer
260 views
Programmatically insert hierarchical terms & set terms for post causes glitch?
I am inserting an array of terms into my custom taxonomy programmatically. Some terms have parents/children. After each term has been entered, I then insert an array of posts into my custom post type. ...
-1
votes
3answers
128 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
vote
0answers
143 views
wp_insert_post - How do I prevent incremental numbers on child pages?
I'm using wp_insert_post to dynamically generate child pages for a given page using a predefined array of values. The goal is to give each child page the same slug.
For example, clicking "Generate ...
0
votes
1answer
83 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
112 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 ...
3
votes
3answers
4k 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.
...
1
vote
2answers
109 views
wp_insert_post() Callback?
After I added a post by wp_insert_post();
Any callback after I added ? I need permalink of added post.
I have idea only search by title and post-type (I use custom post-type in my case), But any ...
1
vote
1answer
248 views
After wp_insert_post(), date_i18n() and date() outputs are adjusted to GMT
I am having a very peculiar issue on a customer's server (vps). The code below works just fine on my servers. Basically, a specific unix timestamp is formatted correctly and as soon as ...
0
votes
1answer
662 views
How to use `wp_insert_user` & `wp_insert_post` simultaneously without `headers already sent` error?
I'm creating a front end posting form using wp_insert_post that asks a user for three basic fields: their first and last name and their email address. If the user is logged in I pre-populate the text ...
0
votes
1answer
136 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
59 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, ...
1
vote
1answer
61 views
Frontend tag edit/submit form
I would like to have a separate page to submit/edit tags.
Any user can edit or submit tags. But it should be published only after admin approval.
Is there any function available like ...
1
vote
1answer
38 views
Add file while inserting post
Is it possible while adding post through wp_insert_post also upload images to this post from url.
1
vote
5answers
717 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 ...
1
vote
2answers
295 views
Making sure wp term relationships records are unique
Which' WordPress function is used in programmatically associating the term taxonomy IDs with post IDs?
And does that function have internal mechanisms to make sure no duplicate entries are allowed ...


