I'm using WPAlchemy on a project.
For a template, I need to use a custom metabox which is working fine with a tinyMCE editor.
Code to insert the meta box on the template (this is a piece of code from https://github.com/helgatheviking/WP-Alchemy-Holy-Grail-Theme/ because I end up trying it after a looooog search, but macache).
<div class="my_meta_control metabox">
<p>
<?php $mb->the_field('richfield');
$settings = array(
'textarea_rows' => '10',
'media_buttons' => 'false',
'tabindex' =>2
);
$val = html_entity_decode($mb->get_the_value());
$id = $mb->get_the_name();
wp_editor($val, $id , $settings );
?>
</p>
<p class="meta-save"><button type="submit" class="button-primary" name="save"><?php _e('Update');?></button></p>
</div>
I have added the following in functions.php
/*
* Recreate the default filters on the_content
* this will make it much easier to output the meta content with proper/expected formatting
*/
add_filter( 'meta_content', 'wptexturize' );
add_filter( 'meta_content', 'convert_smilies' );
add_filter( 'meta_content', 'convert_chars' );
//use my override wpautop
if(function_exists('override_wpautop')){
add_filter( 'meta_content', 'override_wpautop' );
} else {
add_filter( 'meta_content', 'wpautop' );
}
add_filter( 'meta_content', 'shortcode_unautop' );
add_filter( 'meta_content', 'prepend_attachment' );
and for the output :
<div class="content-column content-tab content-richtext">
<?php
global $page_type_richtext;
$page_type_richtext->the_meta(); // don't think I need this line
$richtextcontent = $page_type_richtext->the_value( 'richfield' );
echo apply_filters('meta_content', $richtextcontent );
?>
</div>
But I never manage to have the <p>
tags working. I don't understand where i'm wrong.
I have tried a lot of different ways, using the_content
filter, or wpautop
but it's not working at all.
The display is perfect in the custom field itself inside the admin page. That's why I'm getting mad. The content is correctly wpautop()
when in admin, so I guess the content is properly saved in DB. There must be a way to make it work, but I really don't know. I have find a couple of stack exchange questions about that, like this one but I don't understand how to adapt it. Looks like I should use wpautop
at the saving of the post, but this is handled by WPAlchemy, and wp_editor()
doesn't need it, in theory as I understood it.
Does anyone give me a hind or a lead ?