Last active
August 1, 2025 09:16
-
-
Save nicmare/7224da1be38ab9d92a710fd59b0623df to your computer and use it in GitHub Desktop.
Disable Blocksy Hero Section with Title and Vertical Top Space based upon a term assignment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// disable page title and top spacing when assigned to "schwebende navigation" term of taxonomy "page_props": | |
function disable_blocksy_hero_section($value){ | |
global $post; | |
if(!$post->ID) return $value; | |
$post_options = blocksy_get_post_options($post->ID); | |
// turns out (for some reason) $post->ID is more reliable than $post_id in certain cases! | |
if($p_terms = get_the_terms( $post->ID, 'page_props' )){ | |
if ( ! is_wp_error( $p_terms ) ) { | |
if(in_array("schwebende-navigation",array_column($p_terms,"slug"))){ | |
// disable the hero conditionally: | |
if(isset($post_options["has_hero_section"]) && $post_options["has_hero_section"] == "enabled"){ | |
$value = true; | |
}else{ | |
$value = false; | |
} | |
// disable the top spacing: | |
if(isset($values["vertical_spacing_source"]) && $values["vertical_spacing_source"] == "inherit"){ | |
add_filter('blocksy:vertical-spacing:components', function( $v_spacing_components ) { | |
if (($key = array_search("top", $v_spacing_components)) !== false) { | |
unset($v_spacing_components[$key]); | |
} | |
}); | |
} | |
} | |
} | |
} | |
return $value; | |
} | |
add_filter('blocksy:single:has-default-hero', 'disable_blocksy_hero_section',10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment