But when we use this function the content it returns is not formatted. So many times it happens that we need to use this function and also want formatted content. So below is how can we get formatted content via get_the_content function.
First open your functions.php file exists in your theme folder and paste below code anywhere in your functions.php file.
1 2 3 4 5 6 | function get_the_content_formatted ($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {$content = get_the_content($more_link_text, $stripteaser, $more_file);$content = apply_filters('the_content', $content);$content = str_replace(']]>', ']]>', $content);return $content;} |
In above function we use get_the_content function in first line and in second line we use wordpress filter which is using the_content on $content variable , So we will get formatted content by this function. So after putting this in functions.php, Wherever you want to use formatted content then use get_the_content_formatted() function as given :
1 | echo get_the_content_formatted(); |
I hope this will helpful to you. Please let me know if you have any question.