wp_insert_post() crashing website
wp_insert_post() crashing website
wp_insert_post() crashing website
wp_insert_post limit 25
I found a solution. I just set my own value for the “post_date” field in the wp_insert_post function. As an example: $time = time(); for ($i=0; $i < count($postArgs); $i++) { $postArg = $postArgs[$i]; $postArg[‘post_date’] = $time-$i; wp_insert_post($postArg); }
I have a feeling it has to do with the one database, but I don’t see any errors that would indicate so. Yes, and apparently the structure of the WordPress posts table (wp_040skcp8g2_posts) in the problematic site is corrupted. More specifically, indexes such as the primary key are missing, so you need to add them … Read more
wp_insert_post fails at return statement (nothing is returned to the caller, the error displayed is: The Link You Followed Has Expired)
I remember having a similar issue in a passed and checking if someone published custom post type first was solving the issue for me, something like this: add_action( ‘transition_post_status’, ‘post_create_on_publish_only’, 10, 3 ); function post_create_on_publish_only( $new_status, $old_status, $post ) { if ( ( $new_status == ‘publish’ ) && ( $old_status != ‘publish’ ) && ( … Read more
Why would you need that? ID in a database is auto increment – it manages it’s value itself. If your target is to set custom guid, you should update the inserted post as soon as it is created via wp_update_post right after your $post_id = wp_inserted_post($mypost); like this: …Your code above… $postid = wp_insert_post($mypost); $data … Read more
You could try to use nonces (http://codex.wordpress.org/WordPress_Nonces) in your requests,so even if the request is being sent many times, only 1 time is being saved. You can add in your form this line <form method=”POST”> <input type=”hidden” name=”nonce” value=”<?php echo wp_create_nonce( ‘form-nonce’ );?>” /> …. </form> and in the code where you check : $nonce … Read more
you need to make an array from comma separated string of keywords like $keywords = explode(‘,’, $keywords); then your insert post data array will be. $new_post = array( ‘post_title’ => $title, ‘tax_input’ => array( ‘keyword’ => $keywords ), ‘post_status’ => ‘publish’, ‘post_type’ => ‘test’ );
Ok. Here is an easy fix for that problem. You need to first convert the integer or string to date. See the codes below to understand how to do that: First change this line: $postdate = date($awyear.’-‘.$awmonth.’-‘.$awday.’ ‘.$awhour.’:’.$awminute.’:’.$awsecond); TO $postdate = $awyear.’-‘.$awmonth.’-‘.$awday.’ ‘.$awhour.’:’.$awminute.’:’.$awsecond; Now, convert the $postdate to time string by using strtotime function. $cvtpostdate … Read more