admin管理员组文章数量:1124533
I have a plugin I've written that displays ratings on various pages on my site. It's shortcode based and just drops in on any given page
[mm-rating]
It draws from a field provided by the WP SSO plugin: review rating. The problem is that field is buried pretty deep in several nested panels and I'd like to make it easier for my writers to fill out. I did some experimenting and it looks like I could target the field and update it with JavaScript.
So my question is how hard would it be to include an admin component that.
- Showed up only on "Review" custom post type pages
- Displayed a box in a specific location in the right sidebar
- Included a field for "rating", that when entered would simply update the deeply nested field, but would not itself be considered as part of the post record when submitted?
Note that while I've written a half dozen or so plugins, none of them have dealt with WP Admin, so links to good resources for developing in that area would also be appreciated.
I have a plugin I've written that displays ratings on various pages on my site. It's shortcode based and just drops in on any given page
[mm-rating]
It draws from a field provided by the WP SSO plugin: review rating. The problem is that field is buried pretty deep in several nested panels and I'd like to make it easier for my writers to fill out. I did some experimenting and it looks like I could target the field and update it with JavaScript.
So my question is how hard would it be to include an admin component that.
- Showed up only on "Review" custom post type pages
- Displayed a box in a specific location in the right sidebar
- Included a field for "rating", that when entered would simply update the deeply nested field, but would not itself be considered as part of the post record when submitted?
Note that while I've written a half dozen or so plugins, none of them have dealt with WP Admin, so links to good resources for developing in that area would also be appreciated.
Share Improve this question asked Feb 25, 2024 at 21:19 commadelimitedcommadelimited 258 bronze badges1 Answer
Reset to default 0It's really easy, it's called meta box and you can create one with the following code.
/**
* Register meta box(es).
*/
function plugin_prefix_register_meta_boxes() {
add_meta_box( 'meta-box-id', __( 'My Meta Box', 'textdomain' ), 'plugin_prefix_my_display_callback', 'custom_post_type' );
}
add_action( 'add_meta_boxes', 'plugin_prefix_register_meta_boxes' );
/**
* Meta box display callback.
*
* @param WP_Post $post Current post object.
*/
function plugin_prefix_my_display_callback( $post ) {
// Display code/markup goes here. Don't forget to include nonces!
}
/**
* Save meta box content.
*
* @param int $post_id Post ID
*/
function plugin_prefix_save_meta_box( $post_id ) {
// Save logic goes here. Don't forget to include nonce checks!
}
add_action( 'save_post', 'plugin_prefix_save_meta_box' );
本文标签: plugin developmentDisplay box in sidebar of custom post type
版权声明:本文标题:plugin development - Display box in sidebar of custom post type 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736637349a1945913.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论