the_content()
prints it output to screen. What you want is to return that output and assign a variable to it.
You should note, although get_the_content()
do exactly what you want, it only returns unfiltered content, and not filtered content like the_content()
. You should manually add those filters, which is real easy.
You can do the following
$content = apply_filters( 'the_content', get_the_content() );
EDIT
It seems the above approach pushes the content part to the next line when the filters are applied to get_the_content()
.
A work around here would be to concatenate Output :
to get_the_content()
and then applying the content filters to that
<?php $content = apply_filters( 'the_content', 'Output :' . get_the_content() ); ?>
<?php printf(__( '%1$s', 'theme'), $content); ?>
would give you what you need