Hi,
I am using a code snippet to dynamically display a specific shortcode on the Portfolio archive taxonomy, based on the term ID.
Currently, the shortcode is appearing above the header, but I need it to display below the Woodmart header and above the main content.
Could you please advise on the correct hook to achieve this placement?
Thank you for your assistance.
function add_shortcode_to_project_cat_template($template) {
if (is_tax('project-cat')) {
$term_id = get_queried_object_id();
$shortcodes = [
8 => '[html_block id="4914"]',
9 => '[html_block id="1234"]',
];
add_action('get_header', function () use ($shortcodes, $term_id) {
if (array_key_exists($term_id, $shortcodes)) {
echo do_shortcode($shortcodes[$term_id]);
}
});
}
return $template;
}
add_filter('template_include', 'add_shortcode_to_project_cat_template');
-
This topic was modified 23 hours, 45 minutes ago by akaber.