Problem with wp_insert_post

Because you mention an infinite I am guessing that you are hooked into a hook like save_post that fires for wp_insert_post() so if you hook your code into that your code will run then fire the same hook over and over. To avoid that remove the action from the top of your callback: remove_action(‘save_post’,’yourcallbackfunctionname’); $my_post … Read more

wp_insert_post Only creates draft

The reason why your code created drafts only is status=”pending” make it publish Like // Prepare to save! do_action( ‘wpo_frontend_before_save_order’, $order_details, $user_details ); $post = array( ‘post_title’ => $order_details[‘title’], ‘post_author’ => get_current_user_id(), ‘post_type’ => ‘wp_order’, ‘post_status’ => ‘publish’ ); $postID = wp_insert_post( $post ); if ( is_wp_error( $postID ) ) { set_transient( ‘wpo_new_order_message_’ . get_current_user_id(), … Read more

oEmbded with wp_insert_post() [embedly]

Read up on Embeds. To trigger an embed use wp_oembed_get($url). In general the url needs to be on it’s own line with a space below and above when inside the_content. wp_insert_post() has nothing to do with embeds as the embed HTML is usually generated when passed through the_content filter. To add support for non-oEmbed sites … Read more

Insert multiple posts as parent of the first

If I understand you correctly, this should work: $first_post = true; $post_parent = 0; foreach ( $books as $book ) { $post = array( ‘post_title’ => esc_html__( ‘Post’, ‘book-cpt’ ), ‘post_content’ => ‘test’, ‘post_status’ => ‘publish’, ‘post_type’ => ‘book’, ‘post_parent’ => $post_parent ); $book_id = wp_insert_post( $post ); if ($first_post) { $post_parent = $book_id; $first_post … Read more

$wpdb->insert() does not insert fields

I found the problem. Apparently with the new WP update if you try to insert into a VARCHAR column and the column length is less than what you are trying to insert it just won’t work. Prior to this update it will insert it but trim off the excess characters.

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