Skip to content

Instantly share code, notes, and snippets.

@nicmare
Last active August 1, 2025 09:16
Show Gist options
  • Save nicmare/7224da1be38ab9d92a710fd59b0623df to your computer and use it in GitHub Desktop.
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
<?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