WordPress: save `get_template_part()` to variable

后端 未结 3 1814
滥情空心
滥情空心 2020-12-25 09:43

In short, all I need is to make my WordPress do this

$var = get_template_part( \'loop\', \'index\' ); 

but, get_template_part()

3条回答
  •  轮回少年
    2020-12-25 10:28

    what about?

    $file = file_get_contents(STYLESHEETPATH . '/template-part.php'); 
    return $file;
    

    i'm sure there is a better way, but that seems to work for me.

提交回复
热议问题