get_content() WITH formatting

2010-01-16 @ 14:55

The problem

Normally the get_the_content() tag returns the content WITHOUT formatting. Only the_content() will print the content WITH formatting.

<?php echo get_the_content(); ?>
<?php the_content(); ?>

The solution

I found out a solution in WordPress core to make get_the_content() tag return the same content as the_content(). Put this code into your functions.php in your theme folder.

function get_content($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(']]>', ']]&gt;', $content);
	return $content;

The function call

Call the function inside the loop somewhere in your theme.

<?php echo get_content(); ?>


Do you have any ideas, bugs, features or anything else to improve the code? Write a comment and I’ll look into it

RSS-feed for comments

4 replys to “get_content() WITH formatting”

Leave a reply