Skip to content

Instantly share code, notes, and snippets.

@jprieton
Last active August 29, 2015 14:01
Show Gist options
  • Save jprieton/4fc9835226815291550a to your computer and use it in GitHub Desktop.
Save jprieton/4fc9835226815291550a to your computer and use it in GitHub Desktop.
Crear metadata editable en la pagina contacto
<?php
function jpb_register_meta_box() {
if (!class_exists('RW_Meta_Box') or !is_admin()) {
return;
}
$post_id = $current_post = false;
if (!empty($_POST['post_ID']) or !empty($_GET['post_ID'])) {
$post_id = (int) (!empty($_POST['post_ID']) ? $_POST['post_ID'] : $_GET['post_ID']);
if ($post_id > 0) {
$current_post = get_post($post_id);
}
}
$meta_box = array();
if (is_object($current_post) && $current_post->post_name == 'contacto') {
$meta_box[] = array(
'id' => 'contact_info',
'title' => 'Informacion de Contacto',
'pages' => array('page'),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'name' => 'Coordenadas Google Maps',
'id' => 'map_coord',
'type' => 'text',
),
array(
'name' => 'Tel&eacute;fonos',
'id' => 'phones',
'clone' => true,
'type' => 'text',
),
array(
'name' => 'Correos',
'id' => 'mails',
'clone' => true,
'type' => 'text',
)
));
$meta_box[] = array(
'id' => 'social_networks',
'title' => 'Redes Sociales',
'pages' => array('page'),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'name' => 'Facebook',
'id' => 'facebook',
'type' => 'text',
),
array(
'name' => 'Twitter',
'id' => 'twitter',
'type' => 'text',
),
array(
'name' => 'Google+',
'id' => 'google_plus',
'type' => 'text',
),
array(
'name' => 'Linkedin',
'id' => 'linkedin',
'type' => 'text',
),
array(
'name' => 'Instagram',
'id' => 'instagram',
'type' => 'text',
)
));
}
if (is_array($meta_box) && !empty($meta_box)) {
foreach ($meta_box as $value) {
new RW_Meta_Box($value);
}
}
}
add_action('admin_init', 'jpb_register_meta_box');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment