What is considered the post’s creation date for wp_insert_post?

The short answer is, post_date and post_date_gmt will be set to the date you scheduled the post to be published – not the date you created the post -, so post_date and post_date_gmt are holding the publishing date. Update: As reply to comment: When will the wp_insert_post hook be triggered? Actually both times, so on … Read more

wp_insert_post incorrectly escapes HTML comments when they include tags

The following program: <?php $_SERVER[‘HTTP_HOST’] = ‘localhost’; require_once(‘wp-load.php’); $post = array( ‘post_title’ => ‘HTML Escape’, ‘post_content’ => ‘This is <!– a comment –><br/>This is <!– <p>a comment</p> –>’, ‘post_status’ => ‘publish’ ); $id = wp_insert_post($post); $post = get_post($id); var_export( esc_html( $post->post_content ) ); ?> Outputs the following in the browser: ‘This is <!– a comment … Read more

wp set object terms vs wp set post terms

Right there is no big difference between them, actually wp_set_post_terms() uses wp_set_object_terms() but does few extra check for you. That’s also noted on wp_set_object_terms() Codex page: Perhaps the wp_set_post_terms() is a more useful function, since it checks the values​​, converting taxonomies separated by commas and validating hierarchical terms in integers. http://codex.wordpress.org/Function_Reference/wp_set_object_terms#Notes