Archived topic
echo out to "early"
5 replies · Started by Hans on August 4, 2018
I want to output some individual lines with echo after the post content - the_content();. Unfortunately the echo output is done before content output.
I had that problem some time ago - but I forgot the solution. Any help???
Hi there,
you could use a filter like so:
function db_after_single_content($content) {
if ( is_single() ) {
$aftercontent = 'this appears after the content';
$fullcontent = $content . $aftercontent;
} else {
$fullcontent = $content;
}
return $fullcontent;
}
add_filter('the_content', 'db_after_single_content');
or you could use a the generate_after_content hook:
Hi David,
I use for the time being the hook solution. I want to integrate the additional ouput into my custom post but I do not find the template 'content,single' which has to be changed.
In your function I do not understand how to fill the variable $content when I use the standard template.
Hooks are the best route to take, the filter is handy if you need it inside the_content itself.
The $content is whatever is already in the_content e.g from the WP Editor.
Okay - I stay with the hook. Thanks, David.
You're welcome :)