Skip to content

Instantly share code, notes, and snippets.

@peterwilsoncc
Created March 22, 2021 03:30
Show Gist options
  • Select an option

  • Save peterwilsoncc/65e80a277a1ac1d1d700502638d80fb3 to your computer and use it in GitHub Desktop.

Select an option

Save peterwilsoncc/65e80a277a1ac1d1d700502638d80fb3 to your computer and use it in GitHub Desktop.
<?php
namespace PWCC;
/**
* Register meta box(es).
*/
function wpdocs_register_meta_boxes() {
add_meta_box( 'meta-box-id', __( 'My Meta Box', 'textdomain' ), __NAMESPACE__ . '\\wpdocs_my_display_callback', 'post' );
}
add_action( 'add_meta_boxes', __NAMESPACE__ . '\\wpdocs_register_meta_boxes' );
/**
* Meta box display callback.
*
* @param WP_Post $post Current post object.
*/
function wpdocs_my_display_callback( $post ) {
// Display code/markup goes here. Don't forget to include nonces!
echo "<p>Yo</p>\n";
}
/**
* Save meta box content.
*
* @param int $post_id Post ID
*/
function wpdocs_save_meta_box( $post_id ) {
// Save logic goes here. Don't forget to include nonce checks!
}
add_action( 'save_post', __NAMESPACE__ . '\\wpdocs_save_meta_box' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment