post_date_gmt and post_date [duplicate]

From the comments in the WP_Post class in wp-includes/post.php: You can set the post date manually, by setting the values for ‘post_date’ and ‘post_date_gmt’ keys. So if you’re adding a post programmatically, and you want a date attached, you should set both keys. (If you leave them blank, WordPress will use the appropriate current date … Read more

wp_insert_post to schedule a post – but nothing happens?

As Rarst mentioned I had to use wp_update_post(), but then there is a little trick – one must also set edit_date = true otherwise it has funny behavior. The final code looks like this: function schedule() { $postdate = date(‘2014-06-11 01:00:00’); $postdate_gmt = date(‘2014-06-11 05:00:00’); $post = array( ‘ID’ => 11, ‘post_status’ => ‘future’, ‘post_type’ … Read more

Programmatically add terms to custom post types

I find out the problem and the solution. I debugged the “wp_set_object_terms” by using “is_wp_error” and I got “Invalid Taxonomy” message, then I realized that when the posts was being created that term didn’t exists. So I change the hook to “init” in the programmatically_create_post() function, and voila! Below this line the code working: <?php … Read more

wp_insert_post does not write my post_name

Gr8 job… only thing missing is the action and the timing for it to work… try this: $ins_home = array( ‘post_title’ => ‘Home’, ‘post_name’ => ‘my-home-site’, ‘post_status’ => array(‘publish’), ‘post_type’ => ‘page’, ‘comment_status’ => ‘closed’, ‘ping_status’ => ‘closed’ ); $ins_home_id = wp_insert_post($ins_home, 10, 1); $result = $wpdb->query(“SELECT wpost.post_name FROM $wpdb->posts wpost WHERE wpost.post_name=”my-home-site””); if($result < … Read more

How to insert custom function into wp_insert_post

See those two hooks in the hacked Core code you posted? do_action(‘save_post’, $post_ID, $post); do_action(‘wp_insert_post’, $post_ID, $post); Those are what you need to use to do this right. function run_on_update_post($post_ID, $post) { var_dump($post_ID, $post); // debug include ‘../push/send_message.php’; sendNotification($post[‘post_title’],$post[‘guid’]); return $post_ID; } add_action(‘save_post’, ‘run_on_update_post’, 1, 2); save_post runs every time the post is saved. I … Read more

XMLRPC Avoid duplicate content

Since you add a reference to my previous answer, let me share how I tested it: Setup on site A – XML-RPC Client include_once( ABSPATH . WPINC . ‘/class-IXR.php’ ); include_once( ABSPATH . WPINC . ‘/class-wp-http-ixr-client.php’ ); $client = new WP_HTTP_IXR_CLIENT( ‘http://example.tld/xmlrpc.php’ ); // <– Change! $client->debug = true; $result = $client->query( ‘wp.newPost’, [ 0, … Read more

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