这应该行得通。这是当你点击bookbarklet时,press this获取帖子id的方式。
add_action( \'load-post-new.php\', \'prefix_save_it\' );
function prefix_save_it() {
// define some basic variables
$quick = array();
$quick[\'post_status\'] = \'draft\'; // set as draft first
$quick[\'post_category\'] = isset($_POST[\'post_category\']) ? $_POST[\'post_category\'] : null;
$quick[\'tax_input\'] = isset($_POST[\'tax_input\']) ? $_POST[\'tax_input\'] : null;
$quick[\'post_title\'] = isset($_POST[\'post_title\'] ? $_POST[\'title\'] : null;
$quick[\'post_content\'] = isset($_POST[\'post_content\']) ? $_POST[\'post_content\'] : null;
// insert the post with nothing in it, to get an ID
$post_ID = wp_insert_post($quick, true);
if ( is_wp_error($post_ID) )
wp_die($post_ID);
$quick[\'ID\'] = $post_ID;
wp_update_post($quick);
}
return $post_ID;
}