get_content() WITH formatting
2010-01-16 @ 14:55The 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(']]>', ']]>', $content); return $content; }
The function call
Call the function inside the loop somewhere in your theme.
<?php echo get_content(); ?>
Improvements
Do you have any ideas, bugs, features or anything else to improve the code? Write a comment and I’ll look into it
2010-01-10 @ 2:49 e m
Thanks for this solution, was having troubles with some php scripts there,.
cheers
2010-02-11 @ 7:50 f m
This is excellent, thank you very much!
2010-10-31 @ 10:16 f m
hi, do you also know how to output the content without using wordpress functions directly out of the database eg using echo?
2011-04-02 @ 7:00 e m
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 16387 bytes) in