How to add custom script to the particular Product Category page
Question
I am trying to add the script to the particular Product Category page, but the code is not adding it to the category.
Page (working):
function wpb_hook_faq_javascript() {
if (is_single ('8') || is_page ('8')) {
?>
<script type="application/ld+json">
</script>
<?php }
}
add_action('wp_footer', 'wpb_hook_faq_javascript');
Product Category (not working):
function wpb_hook_faqtocategory_javascript() {
if ( in_category( 'category-name' )) {
?>
<script type="application/ld+json">
</script>
<?php }
}
add_action('wp_footer', 'wpb_hook_faqtocategory_javascript');
But the above code is not working.
Product Category URL:
wp-admin/term.php?taxonomy=product_cat&tag_ID=9&post_type=product
0
actions, categories, javascript
4 years
2020-03-23T20:54:04-05:00
2020-03-23T20:54:04-05:00 0 Answers
107 views
0
Leave an answer