Skip to content

Instantly share code, notes, and snippets.

@tdmrhn
tdmrhn / blc-2-exclude-cpt-from-customizer.php
Created November 15, 2024 08:38
Blocksy 2 exclude custom post types from customizer
<?php
add_filter('blocksy:custom_post_types:supported_list', function($post_types) {
// Remove 'projects' custom post type from the list of supported post types for customizer
$post_types = array_diff($post_types, ['projects']);
return $post_types;
});
@tdmrhn
tdmrhn / woo-show-sale-badge-even-one-variation.php
Created November 12, 2024 11:48
Woo sale badge display even with only one variation
<?php
add_filter('woocommerce_product_is_on_sale', function ($on_sale, $product) {
if ($product->is_type('variable') && (is_shop() || is_product() || is_product_category() || is_product_tag())) {
foreach ($product->get_children() as $variation_id) {
$variation = wc_get_product($variation_id);
if ($variation->is_on_sale()) {
return true;
}
}
}
@tdmrhn
tdmrhn / blc-2-flexy-gallery-expand-trigger.css
Created October 24, 2024 05:31
Blocksy 2 Woo Gallery Expand Lightbox Trigger
@tdmrhn
tdmrhn / blc-2-disable-shop-sort-icon.css
Created October 20, 2024 07:33
Blocksy 2 Disable Shop Sort Icon for mobile
@media (max-width: 689.98px) {
.woo-listing-top .woocommerce-ordering select {
color: inherit;
width: inherit;
padding: 0 15px;
background-image: url("data:image/svg+xml,%3Csvg width='21' height='13' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M18.5.379L20.621 2.5 10.5 12.621.379 2.5 2.5.379l8 8z' fill='%234F5D6D' fill-rule='nonzero'/%3E%3C/svg%3E");
}
.ct-sort-icon {
display: none;
}
@tdmrhn
tdmrhn / blc-2-tags-block-button-type-styling.css
Created October 9, 2024 07:57
Blocksy 2 - WP core Tag block button type styling
.wp-block-post-terms a { background: var(--theme-palette-color-1); color: var(--theme-palette-color-8); padding: 5px 12px; border-radius: 5px; }
.wp-block-post-terms a:hover { background: var(--theme-palette-color-2); }
@tdmrhn
tdmrhn / blc-change-single-product-image-zoom-icon.css
Created September 23, 2024 16:17
Blocksy Single Product Gallery Change Zoom Icon
.woocommerce-product-gallery__trigger::before {
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-6 -6 30 30'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E%0A");
}
@tdmrhn
tdmrhn / blc-pte-filters-mobile-horizontal-scroll.css
Created September 23, 2024 05:52
Blocksy PTE Filters Mobile Horizontal Scrolling
@media only screen and (max-width: 700px) {
.ct-dynamic-filter {
overflow-x: scroll;
flex-wrap: nowrap;
justify-content: left;
padding-bottom: 1rem;
}
.ct-dynamic-filter > * {
flex: 0 0 auto;
@tdmrhn
tdmrhn / blc-2-variation-swatches-container-overflow-slide.css
Created September 19, 2024 09:14
Blocksy 2 Card Variation Swatches Overflow Slide
.ct-card-variation-swatches .variations { align-items: center; }
.ct-card-variation-swatches .ct-variation-swatches {
overflow-x: auto;
scrollbar-width: thin;
padding-bottom: 10px;
justify-content: flex-start;
flex-wrap: nowrap;
max-width: 80%;
}
@tdmrhn
tdmrhn / blc-2-add-custom-hook-before-last-3rd-block.php
Created September 7, 2024 10:41
Blocksy 2 Add Custom Hook to Single Posts Before Last 3rd Block
<?php
add_filter( 'the_content', function ( $content ) {
if ( is_single() ) {
$blocks = parse_blocks( $content );
$block_count = count( $blocks );
$insert_before_block = 3;
$custom_hook_content = apply_filters( 'blocksy:before:certain:last:block', '' );
if ( $block_count >= $insert_before_block ) {
@tdmrhn
tdmrhn / wp-show-sticky-posts-first-in-category.php
Created August 20, 2024 21:31
WP Show Sticky Posts First In Category Query
<?php
add_action('pre_get_posts', function($query) {
if ($query->is_main_query() && !is_admin() && $query->is_category()) {
$sticky_posts = get_option('sticky_posts');
if ($sticky_posts) {
$cat_id = get_queried_object_id();
$sticky_query = new WP_Query([
'post__in' => $sticky_posts,
'cat' => $cat_id,
'posts_per_page' => -1,