Basic Function: Get Template Output as String

 

WordPress function that loads a template file and returns the output as a string.

function get_card_layout(){
ob_start();
include_once plugin_dir_path(__FILE__). "tempalte/cards.php";
$layout = ob_get_content();
ob_end_clean();
echo $layout;
}