Ver Mensaje Individual
  #5 (permalink)  
Antiguo 16/08/2014, 11:06
Avatar de satanson123
satanson123
 
Fecha de Ingreso: julio-2012
Mensajes: 217
Antigüedad: 11 años, 9 meses
Puntos: 2
Respuesta: Campo personalizado wordpress

Cita:
Iniciado por ArturoGallegos Ver Mensaje
Debes utilizarlo como cualquier otro campo que agregues dígase de texto, textarea u otro.

Lo indispensable para guardar y mostrar el campo es que tenga nombre, si ves los argumentos que soporta uno de ellos es textarea_name agrégaselo y procede como lo harías de costumbre con los custom fields
Mi amigo gracias por todo, buscando como 2 horas con google y bing encontre este codigo que funciona perfecto.

Código PHP:
Ver original
  1. define('WYSIWYG_META_BOX_ID', 'my-editor');
  2. define('WYSIWYG_EDITOR_ID', 'myeditor'); //Important for CSS that this is different
  3. define('WYSIWYG_META_KEY', 'extra-content');
  4.  
  5. add_action('admin_init', 'wysiwyg_register_meta_box');
  6. function wysiwyg_register_meta_box(){
  7.         add_meta_box(WYSIWYG_META_BOX_ID, __('WYSIWYG Meta Box', 'wysiwyg'), 'wysiwyg_render_meta_box', 'post');
  8. }
  9.  
  10. function wysiwyg_render_meta_box(){
  11.  
  12.         global $post;
  13.  
  14.         $meta_box_id = WYSIWYG_META_BOX_ID;
  15.         $editor_id = WYSIWYG_EDITOR_ID;
  16.  
  17.         //Add CSS & jQuery goodness to make this work like the original WYSIWYG
  18.         echo "
  19.                <style type='text/css'>
  20.                        #$meta_box_id #edButtonHTML, #$meta_box_id #edButtonPreview {background-color: #F1F1F1; border-color: #DFDFDF #DFDFDF #CCC; color: #999;}
  21.                        #$editor_id{width:100%;}
  22.                        #$meta_box_id #editorcontainer{background:#fff !important;}
  23.                        #$meta_box_id #$editor_id_fullscreen{display:none;}
  24.                </style>
  25.  
  26.                <script type='text/javascript'>
  27.                        jQuery(function($){
  28.                                $('#$meta_box_id #editor-toolbar > a').click(function(){
  29.                                        $('#$meta_box_id #editor-toolbar > a').removeClass('active');
  30.                                        $(this).addClass('active');
  31.                                });
  32.  
  33.                                if($('#$meta_box_id #edButtonPreview').hasClass('active')){
  34.                                        $('#$meta_box_id #ed_toolbar').hide();
  35.                                }
  36.  
  37.                                $('#$meta_box_id #edButtonPreview').click(function(){
  38.                                        $('#$meta_box_id #ed_toolbar').hide();
  39.                                });
  40.  
  41.                                $('#$meta_box_id #edButtonHTML').click(function(){
  42.                                        $('#$meta_box_id #ed_toolbar').show();
  43.                                });
  44.  
  45.                 //Tell the uploader to insert content into the correct WYSIWYG editor
  46.                 $('#media-buttons a').bind('click', function(){
  47.                     var customEditor = $(this).parents('#$meta_box_id');
  48.                     if(customEditor.length > 0){
  49.                         edCanvas = document.getElementById('$editor_id');
  50.                     }
  51.                     else{
  52.                         edCanvas = document.getElementById('content');
  53.                     }
  54.                 });
  55.                        });
  56.                </script>
  57.        ";
  58.  
  59.         //Create The Editor
  60.         $content = get_post_meta($post->ID, WYSIWYG_META_KEY, true);
  61.         the_editor($content, $editor_id);
  62.  
  63.         //Clear The Room!
  64.         echo "<div style='clear:both; display:block;'></div>";
  65. }
  66.  
  67. add_action('save_post', 'wysiwyg_save_meta');
  68. function wysiwyg_save_meta(){
  69.  
  70.         $editor_id = WYSIWYG_EDITOR_ID;
  71.         $meta_key = WYSIWYG_META_KEY;
  72.  
  73.         if(isset($_REQUEST[$editor_id]))
  74.                 update_post_meta($_REQUEST['post_ID'], WYSIWYG_META_KEY, $_REQUEST[$editor_id]);
  75.  
  76. }

Y para mostrarlo

Código PHP:
<?php $content get_post_meta($post->IDWYSIWYG_META_KEYtrue); ?>
<p><?php echo $content?></p>