I am trying to use this method to include a template part (HTML Code) rather than using some plain text. When I use text, it shows correctly below the content with the the_content filter. However, If I try to get_template_part, the content shows at the top of the Wordpress post rather than below the content.
Is there a better way to include/get template parts hooked to the before/after of single content in Wordpress?
Here is the code I am trying with the filter:
function educadme_book_fields_content_hook( $content ) {
if( is_singular('books') ) {
$beforecontent = '';
$aftercontent = get_template_part( 'parts/book', 'fields' );
$fullcontent = $beforecontent . $content . $aftercontent;
return $fullcontent;
}
Also tried:
$content .= get_template_part( 'parts/book', 'fields' );
return $content;
Still getting the same issue as all content of the get_template_part are shown above even the title, not just the_content. Thanks!