Skip to content

Instantly share code, notes, and snippets.

@nicmare
nicmare / functions.php
Last active August 1, 2025 09:16
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' )){
@nicmare
nicmare / functions.php
Created July 30, 2025 08:30
Change Blocksy Vertical Spacing based on taxonomy term
<?php
function change_blocksy_vertical_spacing($v_spacing_components){
global $post;
if($p_terms = get_the_terms( $post->ID, 'page_props' )){ // change "page_props" to your custom taxonomy name
if ( ! is_wp_error( $p_terms ) ) {
if(in_array("schwebende-navigation",array_column($p_terms,"slug"))){ // change "schwebende-navigation" to your term name
if (($key = array_search("top", $v_spacing_components)) !== false) {
unset($v_spacing_components[$key]);
}
}
@nicmare
nicmare / functions.php
Last active August 1, 2025 09:19
disable blocksy hero section based on an assigned term
<?php
// disable page title when assigned to schwebende navigation:
function disable_blocksy_hero_section($value){
global $post;
if(!$post->ID) return $value;
if($p_terms = get_the_terms( $post_id, 'page_props' )){ // replace "page_props" with your custom taxonomy name
if ( ! is_wp_error( $p_terms ) ) {
if(in_array("schwebende-navigation",array_column($p_terms,"slug"))){ // replace "schwebende-navigation" with your term
$value = false;
@nicmare
nicmare / style.css
Created July 23, 2025 09:36
blocksy archive item: span it across two or more rows:
/**
* add this to your theme style.css and change the aria-label value to your needs
*/
.entries article.entry-card:has(a[aria-label="2/1 Seite Panorama"]){
grid-column: 1 / 3;
}
.entries article.entry-card a[aria-label="2/1 Seite Panorama"] img {
aspect-ratio: 5 / 3 !important;
}
@nicmare
nicmare / style.css
Last active August 1, 2025 09:20
making blocksy archive item fully clickable and animating the shadow
/**
* put it in your themes style.css and change "blog" to your post type name
* if your CPT is "product", you change the value "blog" to "product_archive" or "rooms_archive"
*/
[data-prefix="blog"] .entries article.entry-card {
position:relative;
transition:box-shadow .15s ease-in-out, transform .15s ease-in-out;
}
[data-prefix="blog"] .entries article.entry-card .entry-title > a::before {
@nicmare
nicmare / functions.php
Last active August 1, 2025 09:20
blocksy dynamic data block combining two acf fields
<?php
function blocksy_dyn_block_pricelist($html, $block){
if($block["blockName"] != "blocksy/dynamic-data") return $html;
if(!isset($block["attrs"]["field"])) return $html;
if($block["attrs"]["field"] != "acf:preisliste_text") return $html; // change acf field-name "preisliste_text" here
if($has_link = get_field("preisliste_link"))
$html = '<a href="'.$has_link.'" target="_blank">'.$html.'</a>';
return $html;
<?php
// register the style selection for advanced posts block:
function register_block_styles() {
if ( function_exists( 'register_block_style' ) ) {
register_block_style(
'blocksy/query',
array(
'name' => 'mobile-slider',
'label' => __("mit Slider","lmdm") // change label to your needs
)
<?php
function change_blocksy_menu_label() {
global $menu;
foreach($menu as $key=>$one){
if(isset($one[0]) && $one[0] == "Blocksy"){
$menu[$key][0] = "My Custom Theme Settings";
// create custom base64 image with a svg and converter here:
// https://www.fffuel.co/eeencode/
// $menu[$key][6] = "data:image/svg+xml;base64,PHN2ZyBmaWxsPSIjZjBmMGYxIiB2aWV3Qm94PSIwIDAgMzIgMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgaWQ9IkxheWVyXzEiIGRhdGEtbmFtZT0iTGF5ZXIgMSI+PGcgaWQ9IlNWR1JlcG9fYmdDYXJyaWVyIiBzdHJva2Utd2lkdGg9IjAiPjwvZz48ZyBpZD0iU1ZHUmVwb190cmFjZXJDYXJyaWVyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjwvZz48ZyBpZD0iU1ZHUmVwb19pY29uQ2FycmllciI+PHBhdGggZD0iTTI5LjIyLDEzLjk1aC0uMjh2LTIuMDdjMC00Ljc1LTUuNzYtOC42MS0xMi44NC04LjYxUzMuMjYsNy4xNCwzLjI2LDExLjg4djIuMDdoLS40OGMtLjg0LDAtMS41MiwuNjgtMS41MiwxLjUydjEuMDZjMCwuODQsLjY4LDEuNTIsMS41MiwxLjUyaC40OHYyLjA3YzAsNC43NCw1Ljc2LDguNiwxMi44NCw4LjZzMTIuODQtMy44NiwxMi44NC04LjZ2LTIuMDdoLjI4Yy44NCwwLDEuNTItLjY4LDEuNTItMS41MnYtMS4wNmMwLS44NC0
@nicmare
nicmare / remove-blocksy-patterns.php
Last active August 1, 2025 09:21
This snippet removes the default patterns and "blocksy" pattern category created by blocksy theme
<?php
add_action("init", "init_blocks_and_patterns",100);
function init_blocks_and_patterns(){
if(\WP_Block_Pattern_Categories_Registry::get_instance()->is_registered("blocksy")){
unregister_block_pattern_category( 'blocksy');
$blocksy_patterns = [
"posts-layout-1",
"posts-layout-2",
"posts-layout-3",
"posts-layout-4",
@nicmare
nicmare / blocksy-ajax-search.php
Last active February 1, 2024 10:19
This Code Snippet modifies the Wordpress Search Terms
<?php
function search_replacement($term){
return ltrim(str_replace( array('0x'), array('0 x '), urldecode(strtolower($term)) ));
}
// ajax search:
function replace_search( $query_object )
{
if( $query_object->is_search() ) {
$raw_search = $query_object->query['s'];