hi,
i have a problem with the_content.
i want to add a div to the_content so i have created a function
function like_content($content) {
global $post;
$content = "<div class=\"ikaz\">";
$content .= "hello all";
$content .= "</div>";
$content .= $post->post_content;
return $content;
}
add_filter( 'the_content', 'like_content' );
it works good but not formatting because of $post->post_content. what can i do for formatting it?
i solved the problem like that. i dont use $post->post_content. it is unnecessary. anyway you get formated content from the function.
function like_content($content) {
global $post;
$original = $content;
$content = "<div class=\"ikaz\">";
$content .= "hello all";
$content .= "</div>";
$content .= $original;
return $content;
}
add_filter( 'the_content', 'like_content' );
That's what I was looking for for a while now. You could also assign the content using get_the_content() function to a variable, then concatenate it with your desired content.
But always, when using $content .= without first reading it into a variable, will add your content at the beginning of the post's content. Been through that.
Hmm, I'm having problems getting this to work. Just created a new post here about it;
http://wordpress.org/support/topic/407300?replies=1#post-1542139