Skip to main content

Hide video module

Comments

1 comment

  • Ariel H.

    Hi,

    Thank you for contacting us.

    To achieve this functionality, you’ll need to add some custom code to your site. You can place the following snippet in your functions.php file or use a plugin like WPCode to add it safely:

     add_action('wp_head', function () {
        if (is_singular('tours') && function_exists('get_field')) {
            // Retrieve the 'videolink' field value
            $videolink = get_field('video_link');
            
            if (empty($videolink)) {
                // Inject CSS to hide the video content if the field is empty
                echo '<style>
                    .brz .brz-video .brz-video-content {
                        display: none;
                    }
                </style>';
            }
        }
    });

    In this example, 'tours' is the slug for the custom post type created using CPT UI, and video_link is the custom field added via ACF. The code checks whether the video_link field is empty and, if so, hides the .brz-video-content element by applying display: none;.

    You may adjust the code further if you want to validate whether the value entered in the video_link field is a valid YouTube video URL.

    I’ve tested this on the following URL: https://demo.pro-site.cloud/demo01/tours/. Look for the title labeled "(with video)"—the rest do not have videos.

    I hope this helps.

    Best regards,
    Ariel H.

    0

Please sign in to leave a comment.