Home › Forums › Front-end Issues › If repeater field in functions.php › Reply To: If repeater field in functions.php
You’ll want to use the acf/input/admin_footer action to run jQuery for this. Also, I would create the tab that you want in the field group.
Basically, you could look to see if there are rows in the body of that repeater field table then hide the tab if there are no rows . This script will get triggered when the edit post page is ready.
It would look something like this:
function check_for_videos() {
?>
<script>
var rowCount = jQuery('#acf-group_571814caa0f78 table tbody).find('tr');
if(rowCount.length == 0 ){
jQuery('tab field selector here').hide();
}
</script>
<?
}
add_action('acf/input/admin_footer', 'check_for_videos');
The most challenging part for me when doing this is getting the selector field correct to run the jQuery. If you’re not familiar with jQuery, you have to refer to the element that you want to run the script on and sometimes it’s hard to nail that down.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.