You are viewing an old revision of this post, from October 4, 2012 @ 03:10:30. See below for differences between this version and the current revision.

get_the_content() WITH formatting

See this post: http://www.web-templates.nu/2008/08/31/get_the_content-with-formatting/ Normally the get_the_content() tag returns the content without formatting. I found out a solution to makeget_the_content() tag return the same content as the_content(). [php] function get_the_content_with_formatting ($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; } [/php] In your theme, call the function within the loop: [php] get_the_content_with_formatting(); [/php]

Revisions

Revision Differences

October 4, 2012 @ 03:10:30Current Revision
Content
Deleted: See this post:Added: See this post: http://www.web- templates.nu/ 2008/08/31/get_ the_content-with-formatting/
Unchanged: Normally the <em>get_ the_content()</em> tag returns the content without formatting. I found out a solution to make<em>get_the_ content()</em> tag return the same content as <em>the_content()</em>.Unchanged: Normally the <em>get_ the_content()</em> tag returns the content without formatting. I found out a solution to make<em>get_the_ content()</em> tag return the same content as <em>the_content()</em>.
Unchanged: [php]Unchanged: [php]
Unchanged: function get_the_content_ with_formatting ($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {Unchanged: function get_the_content_ with_formatting ($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
Unchanged: $content = get_the_content( $more_link_text, $stripteaser, $more_file);Unchanged: $content = get_the_content( $more_link_text, $stripteaser, $more_file);
Unchanged: $content = apply_filters( 'the_content', $content);Unchanged: $content = apply_filters( 'the_content', $content);
Unchanged: $content = str_replace(']]&gt;', ']]&amp;gt;', $content);Unchanged: $content = str_replace(']]&gt;', ']]&amp;gt;', $content);
Unchanged: return $content;Unchanged: return $content;
Unchanged: }Unchanged: }
Unchanged: [/php]Unchanged: [/php]
Unchanged: In your theme, call the function within the loop:Unchanged: In your theme, call the function within the loop:
Unchanged: [php]Unchanged: [php]
Unchanged: get_the_content_ with_formatting();Unchanged: get_the_content_ with_formatting();
Unchanged: [/php]Unchanged: [/php]

Note: Spaces may be added to comparison text to allow better line wrapping.

Tags: ,

No comments yet.

Leave a Reply