我正在尝试将元盒添加到从特定帖子模板创建的任何帖子的底部。ie我不想在我所有的帖子上都有元数据库,只想在某些帖子上。
当我决定添加操作来绘制和保存元盒数据时,如果我可以访问帖子,我可以查看它使用的模板,然后继续绘制元盒或退出。
add_action( \'load-post.php\', \'post_metabox_setup\');
function post_metabox_setup() {
//decide whether to add draw and save actions here
}
如何在“post\\u metabox\\u setup function”中访问$post或$post\\u id。我试过这样做:add_action( \'load-post.php\', \'post_metabox_setup\');
function post_metabox_setup($post_id) {
//but here $post_id an empty string when the post loads in the editor
}
有人知道怎么做吗?