Support

Account

Forum Replies Created

  • Is there any way to use this for the DIVI GALLERY EXTENDED plugin instead?

    https://www.elegantthemes.com/marketplace/divi-gallery-extended/

  • This code got what I needed. Make sure to add the #hide_this_div to the whatever you want to hide and change the ‘ACF-field-name’ in this code to your field name. You can change the ‘post’ to any CPT.

    add_action('template_redirect', 'hide_disabled_blocks');
    
    function hide_disabled_blocks() {
    	global $post;
    	
    	// get dynamic project id
        $post_id = $post->ID;
    	
    	// get value of true-false field in each post
    	$hidediv = get_post_meta($post_id, 'ACF-field-name', true);
    	
    	if is_singular( 'post' ) :?>
    	
    	<style type="text/css">
    		<?php
    		
    		// if "ACF true-false command" is false, hide the Div ID
    		if  ( ($hidediv == '0') || (empty($hidediv)) ): ?>
    			#hide_this_div { display: none; }
    		<?php endif;
    		
    		?>
    	</style>
  • Try this code. Make sure to add the #hide_this_div to the whatever you want to hide:

    add_action('template_redirect', 'hide_disabled_blocks');
    
    function hide_disabled_blocks() {
    	global $post;
    	
    	// get dynamic project id
        $post_id = $post->ID;
    	
    	// get value of true-false field in each post
    	$hidediv = get_post_meta($post_id, 'ACF-field-name', true);
    	
    	if is_singular( 'post' ) :?>
    	
    	<style type="text/css">
    		<?php
    		
    		// if "ACF true-false command" is false, hide the Div ID
    		if  ( ($hidediv == '0') || (empty($hidediv)) ): ?>
    			#hide_this_div { display: none; }
    		<?php endif;
    		
    		?>
    	</style>
Viewing 3 posts - 1 through 3 (of 3 total)