Insert 'p' tag to content value the way wordpress does

Usually I am annoyed at how WP editor inserts <p> to my content, but now I have a front end wp_editor for a featured area with a buddypress profile. The problem is that when I echo out the value of this field to the public profile the text is formatted but smashed together because the magical <p> that Wordpress usually puts in are not present with my current approach. Here is my echo in the profile-loop.php

foreach ( $featured_content as $content ){
    _e('<div id="featured_area_content">'.stripslashes($content->content).'</div>');
}
  • Div Truth
    • Design Lord, Child of Thor

    NOTE: the single quotes around the table_name (which is a custom table) are actually backtics (can't use them in this forum within codeblocks though)

    $featured_content = $wpdb->get_results( "SELECT id, content FROM 'table_name' WHERE user_id = $user_id LIMIT 1" );
    if ( $featured_content ){
        _e('<div id="featured_area">');
        foreach ( $featured_content as $content ){
            e('<div id="featured_area_content">'.stripslashes($content->content).'</div>');
        }
        _e('</div>');
    }

    Thanks Arun. hope this helps you. Let me know if there is anything else you need.

  • chocks
    • New Recruit
    function chocks_wyswyg_meta_output($metabox_name) {
    	global $post;
    	$output = get_post_meta($post -> ID, "$metabox_name", true);
    	$output = apply_filters('the_content', $output);
    	$output = str_replace(']]>', ']]>', $output);
    	echo $output;
    }

    that is what I use to output a wyswyg content from a metabox. Given the metabox name I echo the content well formated the way wordpress does with the_content()

    Makes sense?

  • Div Truth
    • Design Lord, Child of Thor

    So this is what I updated my code with but it didn't work:

    $featured_content = $wpdb->get_results( "SELECT id, content FROM  'featured_area' WHERE user_id = $company_id LIMIT 1" );
    
    if ( $featured_content ){
        _e('<div id="featured_area">');
        foreach ( $featured_content as $content ){
    	$output = apply_filters('the_content', $content->content);
    	$output = str_replace(']]>', ']]>', $output);
    	_e('<div id="featured_area_content">'.$output.'</div>');
        }
        _e('</div>');
    }

    I also noticed that my WYSIWIG is adding slashes to the data when I use the $wpdb->update(). In order to make sure this wasn't the issue though I grabbed the data from a post and manually updated this test account. The issue remains, I don't get the magical <p> and <br> tags that WP usually exports content with.

    Any more thoughts? Or need anything else from me?

  • Div Truth
    • Design Lord, Child of Thor

    Ok so good news I was able to resolve this myself. Still had slashes in my content using that $wpdb->update() method but I was able to strip those out on the out put and now I have magical <p> and
    tags by exporting like so:

    $output = wpautop(stripcslashes($content->content));
    _e('<div id="featured_area_content">'.$output.'</div>');

    Thanks though for the advice.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.