admin管理员组文章数量:1291010
I am trying to add custom metaboxes to only those pages that use a certain custom template that is applied to them.
How can i do this? I based on this this guide: How to add add_meta_box to specific Page Template?
But it doesn't work for me. How come?
This is my code in functions.php:
add_action("admin_init", "metabox_bookmaker");
function metabox_bookmaker(){
global $post;
if ( 'page-templates/template-bookmaker.php' == get_post_meta( $post->ID, '_wp_page_template', true ) ) {
add_meta_box("metabox_bookmaker_custom", "Metabox per Single Bookmaker", "custom_metabox_bookmaker", "page", "normal", "high");
}
}
本文标签: Add metabox to pages that use custom template in WordPress
版权声明:本文标题:Add metabox to pages that use custom template in WordPress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741503409a2382179.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论