我正在尝试在发布时插入帖子 ID 到自定义表,但它没有添加正确的 ID,但这里 0 是我的函数
//get post id on publish
function get_publishing_id($post_id) {
$post= get_post($post_id);
if ($post->post_type == 'post'
&& $post->post_status == 'publish') {
// insert data on publish
global $wpdb;
$wpdb->insert(
$wpdb->prefix.'banner_views',
array(
'postid' => $post,
'view_count' => 12,
)
);
} // end if
} // end function
add_action('save_post','get_publishing_id');
请帮助解决这个问题。非常感谢...