Skip to content

Instantly share code, notes, and snippets.

@jmabbas
Created June 27, 2024 11:24
Show Gist options
  • Save jmabbas/32fa3eeee06ff98c1222cb320eaab1ba to your computer and use it in GitHub Desktop.
Save jmabbas/32fa3eeee06ff98c1222cb320eaab1ba to your computer and use it in GitHub Desktop.
Vodi - Hide tab tittle there is no movies
function vc_child_hide_person_tabs_there_is_no_content() { ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
function hasRequiredContent(tabPane, requiredClass) {
return tabPane.querySelector('.' + requiredClass) !== null;
}
const tabPanes = document.querySelectorAll('.tab-content > .tab-pane');
const navItems = document.querySelectorAll('.nav > .nav-item');
if (hasRequiredContent(tabPanes[1], 'person-cast-movie')) {
navItems[1].style.display = 'flex'; // Show the second nav item
} else {
navItems[1].style.display = 'none'; // Show the second nav item
}
if (hasRequiredContent(tabPanes[2], 'person-cast-tv-show')) {
navItems[2].style.display = 'flex'; // Show the third nav item
} else {
navItems[2].style.display = 'none'; // Show the second nav item
}
});
</script>
<?php }
add_action( 'wp_head', 'vc_child_hide_person_tabs_there_is_no_content', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment