admin管理员组文章数量:1300023
Meta Tags - Undefined array due to meta tags!
I have created my own custom post meta tags but all works fine until I test my WordPress theme on the new WordPress Installation.
What I came through after the new WordPress installation, I have activated my theme, and when I try to open post or pages section inside WordPress admin. It triggers an errors
1. Warning: Undefined array key "your_meta_box_nonce"
I solved it by adding -> [ isset($_POST['your_meta_box_nonce']) &&
] inside first condition
function save_your_fields_meta( $post_id ) {
// verify nonce
if ( [ --Added Here-- ] !wp_verify_nonce( $_POST['your_meta_box_nonce'], basename(__FILE__) ) ) {
return $post_id;
}
}
add_action( 'save_post', 'save_your_fields_meta' );
2. Warning: Undefined array key "post_type" and Warning: Undefined array key "your_fields"
I soved it by adding -> [ isset($_POST['post_type']) &&
]
// check permissions
if ( [ --Added Here-- ] 'page' === $_POST['post_type'] ) {
if ( !current_user_can( 'edit_page', $post_id ) ) {
return $post_id;
} elseif ( !current_user_can( 'edit_post', $post_id ) ) {
return $post_id;
}
}
and -> [ isset($_POST['your_fields']) &&
]
if ( [ --Added Here-- ] $_POST['your_fields'] !== $old ) {
update_post_meta( $post_id, 'your_fields', $_POST['your_fields'] );
} elseif ( isset($_POST['your_fields']) && '' === $_POST['your_fields'] && $old ) {
delete_post_meta( $post_id, 'your_fields', $old );
}
Errors are solved but the page is completely blank.
Below is my full code of the meta save_post function
Update -:
I have checked my code again and set my define(‘WP_DEBUG’, true);
but it still does not show an error means the blank page.
So I tried to hide my code and when I did it. I found that when I set priority to default, core, high, low it triggers gets blank but when I set priority to any numeric value it appears again but obesity it did not display the custom meta box
Below is the complete code of my custom meta field.
本文标签: metaboxPost and Pages section inside WordPress admin are completely blank
版权声明:本文标题:metabox - Post and Pages section inside WordPress admin are completely blank 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741651149a2390487.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论