Search code examples
wordpresstext-formatting

Output formatted Text in WordPress (ul and li changed to p tag issue)


I am using a readymade theme in which the Job description is not showing Formatted Text.

Below are few lines of WordPress single post code:

$job_about_me = html_entity_decode(get_post_meta($post->ID, htmlentities(stripslashes('job-about-me')),true));

$content = $job_about_me;

                        $content = apply_filters('the_content', $content);
                        $content = str_replace(']]>', ']]>', $content);
                        echo wpautop($content);

So, the output of this code is as shown below:

.full {
    margin-left: 0;
    width: 100%;
    float: left;
    position: relative;
    margin-bottom: 30px;
}
<div class="full" style="margin-bottom: 0;">
						<p>Shirish</p>
<p>Gururaj</p>
<p>Jay</p>
					</div>

I want the output of the code to be in ul and li but not p tags.

In short a Formatted HTML page should be visible.

I tried a lot but need your help.


Solution

  • Why not try str_replace()?

    echo str_replace(
        array( '<div', '</div>' '<p', '</p>'  ),
        array( '<ul', '</ul>', '<li', '</li>' ),
        wpautop( $content )
    );