wp_insert_post order problem

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); }

“transition_post_status” action creating two post with wp_insert_post

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

Inserting post_id into guid before wp_insert_post

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

wp_insert_post creating duplicate post with Safari

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

Setting Post Date Returning “Notice: A non well formed numeric value encountered”

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)