drkskwlkr icon

Greenshift Visibility Block filtering via PHP conditions

drkskwlkr | PRO | 07/12/25 11:35:30 PM UTC (Edited) | 0 ⭐ | 10255 👁️ | Never ⏰ | []
PHP |

540 B

|

Source Code

|

0 👍

/

0 👎

<?php
add_filter('render_block', 'custom_visibility_conditions_check', 11, 2);
 
// Don't forget to specify block ID and the CPT slugs in $allowed_post_types
function custom_visibility_conditions_check($block_content, $block){
    if(isset($block['attrs']['id']) && $block['attrs']['id'] == 'gsbp-xxxxxxx') {
        $allowed_post_types = array('books', 'movies');
        
        if(is_singular($allowed_post_types)){
            return $block_content;
        } else {
            return '';
        }
    }
    return $block_content;
}
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎