I have "<em><?php echo nl2br(the_content()); ?></em>"
but the two "
are not inline with the content. How do I keep the before and after "
characters inline?
1 Answer
You'd want to use get_the_content()
because the_content()
echos the output immediately:
echo nl2br( '"<em>' . get_the_content() . '</em>"' );
Depending on what the content contains, you still may run into unexpected results, for example, if the content ends with an unordered list.
If you want to add the quote marks and <em>
tags to the content before the standard filters are applied, you can use this approach:
echo nl2br( apply_filters( 'the_content',
'"<em>' . get_post_field( 'post_content', get_the_ID() ) . '</em>"' ) );