drkskwlkr

Greenshift Visibility Block filtering via PHP conditions

Jul 12th, 2025 (edited)
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | Source Code | 0 0
  1. <?php
  2. add_filter('render_block', 'custom_visibility_conditions_check', 11, 2);
  3.  
  4. // Don't forget to specify block ID and the CPT slugs in $allowed_post_types
  5. function custom_visibility_conditions_check($block_content, $block){
  6.     if(isset($block['attrs']['id']) && $block['attrs']['id'] == 'gsbp-xxxxxxx') {
  7.         $allowed_post_types = array('books', 'movies');
  8.        
  9.         if(is_singular($allowed_post_types)){
  10.             return $block_content;
  11.         } else {
  12.             return '';
  13.         }
  14.     }
  15.     return $block_content;
  16. }
  17.  
Advertisement
Add Comment
Please, Sign In to add comment