As a Hatena Bookmark specification, if you send an email to the email address at Bookmark Settings > Bookmark by Email > Email Posting Address with URL + comment in the body, you can bookmark it.
By sending an email to this address, you can bookmark the page described in the body. The format is "comment `http://URL/`" or "`http://URL/` comment". The subject is ignored.
Using this, let’s try posting from WordPress to the Hatena Bookmark email address using the action hook when publishing an article.
Use transition_post_status and wp_mail.
Add the following to the child theme’s functions.php.
add_action( 'transition_post_status', function( $new_status, $old_status, $post ) {
if ( 'publish' == $new_status && 'publish' != $old_status && 'post' == $post->post_type ) {
wp_mail('[email protected]','hatebu', "[Read Later] comment. " . ' ' . get_permalink($post_id) ,'From:[email protected]');
}
}, 10, 3 );
Now, change [email protected] to your own Hatena Bookmark email address.