I want to wrap an opening and closing shortcode function in WordPress around a get_template_part('path/file'). Instead of the code wrapping around in the HTML output, it shows below the content.
Example below:
PHP output:
<?php
function get_products($atts = [], $output = null) {
PHP outout:
$output= get_template_part('partials/modules/content', 'fields');
$output .= '[shortcode]'. $output .'[/shortcode]';
$output .= ob_get_clean();
return $output;
}
add_shortcode('resources', 'get_products');
?>
<?php echo do_shortcode('[resources]'); ?>
Html output:
<div class="content">
</div>
<div class="shortcode">
</div>
Html desired output:
<div class="shortcode">
<div class="content">
</div>
</div>