Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add meta to regular page post
// register your custom meta box
function my_slider_properties_meta_box() {
add_meta_box('my_slider_properties', 'Link Format Title URL', 'my_slider_properties', 'page', 'side', 'default');
add_action('add_meta_boxes', 'my_slider_properties_meta_box');
// echo your custom meta box
function my_slider_properties() {
global $post;
$my_slider_id = get_post_meta($post->ID, '_my_slider_id', true);
echo '<p>My slider id</p>';
echo '<input type="text" name="_my_slider_id" value="' . esc_attr($my_slider_id) . '" size="40" />';
// process your custom meta box while saving
function my_slider_properties_save_meta($post_id, $post) {
if ( !current_user_can( 'edit_post', $post->ID ))
return $post->ID;
$metas['_my_slider_id'] = $_POST['_my_slider_id'];
foreach ($metas as $key => $value) {
update_post_meta($post->ID, $key, $value);
add_action('save_post', 'my_slider_properties', 1, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment