function get_blocks($blockNames = []) {
$t = [];
foreach ($blockNames as $block) {
ob_start();
get_template_part('components/' . $block);
$t[$block] = ob_get_contents();
ob_end_clean();
}
die(json_encode($t));
}
$blocks = get_blocks(['article-block', 'another-block']);
/*
* {
* 'article-block': // контент,
* 'another-block': // контент,
* }
*/
strong {
font-weight: normal;
}
Держите, я за вас погуглил: https://github.com/OssamaRafique/Interactive-Image...