Skip to content

Instantly share code, notes, and snippets.

@tdmrhn
tdmrhn / blc-2-preload-mini-cart-css.php
Last active February 29, 2024 13:55
Blocksy 2 Preload Mini Cart CSS file
View blc-2-preload-mini-cart-css.php
<?php
add_action('wp_enqueue_scripts', function() {
$theme = blocksy_get_wp_parent_theme();
wp_enqueue_style(
'ct-legacy-mini-cart-styles',
blocksy_cdn_url(
get_template_directory_uri() . '/static/bundle/cart-header-element-lazy.min.css'
),
[],
@tdmrhn
tdmrhn / blc-posts-shortcode-add-author-arg.php
Last active February 26, 2024 16:33
Blocksy Posts Shortcode Add Author IDs arg
View blc-posts-shortcode-add-author-arg.php
<?php
add_filter('blocksy:general:shortcodes:blocksy-posts:args', function ($query_args, $shortcode_args) {
if (isset($shortcode_args['author_ids'])) {
$author_ids = array_map('intval', explode(',', $shortcode_args['author_ids']));
$query_args['author__in'] = $author_ids;
}
return $query_args;
}, 10, 2);
@tdmrhn
tdmrhn / blc-2-exclude-out-of-stock-products-upsell.php
Created February 23, 2024 11:44
Blocksy 2 Exclude Out of Stock products from related and upsells
View blc-2-exclude-out-of-stock-products-upsell.php
<?php
add_filter( 'woocommerce_output_related_products_args', function ( $args ) {
$args['status'] = 'publish';
$args['limit'] = -1;
$args['stock_status'] = 'instock';
return $args;
}, 10, 1 );
@tdmrhn
tdmrhn / blc-2-mobile-pagination-numbers.css
Created February 23, 2024 06:12
Blocksy 2 Simplify Pagination Numbers in Mobile View
View blc-2-mobile-pagination-numbers.css
@media (max-width: 689.98px) {
[data-pagination="simple"] > div .page-numbers
{ margin: 2px; }
[data-pagination="simple"] > div .page-numbers:nth-child(3),
[data-pagination="simple"] > div .page-numbers:nth-child(4),
[data-pagination="simple"] > div .page-numbers:nth-child(8),
[data-pagination="simple"] > div .page-numbers:nth-child(9)
{ display: none; }
}
@tdmrhn
tdmrhn / blc-2-echo-content-block-if-acf-exist.php
Created February 17, 2024 12:40
Blocksy 2 Content Blocks + ACF condition
View blc-2-echo-content-block-if-acf-exist.php
<?php
add_filter('blocksy:single:top', function () {
if (get_field('my-field')) {
echo do_shortcode('[blocksy-content-block id="XXX"]');
}
});
@tdmrhn
tdmrhn / blocksy-2-masonry-grid.css
Created February 15, 2024 12:22
Blocksy 2 Blog Posts Masonry Grid
View blocksy-2-masonry-grid.css
[data-prefix="blog"] section .entries {
display: block;
--masonry-column: 3;
-webkit-column-count: var(--masonry-column);
-moz-column-count: var(--masonry-column);
column-count: var(--masonry-column);
}
[data-prefix="blog"] section .entries article {
display: inline-block;
@tdmrhn
tdmrhn / blc-2-add-related-brand-products-with-content-bocks.php
Last active January 24, 2024 11:15
Blocksy 2 Brand based related products with Content Blocks Hook + Code Editor Block
View blc-2-add-related-brand-products-with-content-bocks.php
@tdmrhn
tdmrhn / blc-2-sticky-post-navigation.css
Created January 23, 2024 21:00
Blocksy 2 Sticky Post Navigation
View blc-2-sticky-post-navigation.css
@media (min-width: 1000px) {
// replace for CPT also replace CPT slug with project
// .single-project .post-navigation
.post-navigation { position: fixed; top: 47%; width: 100vw !important; max-width: 96vw !important; left: 2vw; right:2vw; }
}
@tdmrhn
tdmrhn / blc-2-add-content-block-in-shop-loop.php
Created January 23, 2024 10:13
Blocksy 2 Add a Content Block after certain shop loop item
View blc-2-add-content-block-in-shop-loop.php
<?php
add_action('woocommerce_after_shop_loop_item', function () {
if (wc_get_loop_prop('loop') === 3) {
echo '<li>' . do_shortcode('[blocksy-content-block id="XXX"]') . '</li>';
}
});
@tdmrhn
tdmrhn / blc-2-add-swipe-function-post-navigation.html
Created January 22, 2024 14:40
Blocksy 2 Add Swipe Function to Single Posts Navigation
View blc-2-add-swipe-function-post-navigation.html
<script>
const postNavigation = document.querySelector('.post-navigation');
let startX;
postNavigation.addEventListener('touchstart', e => startX = e.touches[0].clientX);
postNavigation.addEventListener('touchend', e => {
const diffX = startX - e.changedTouches[0].clientX;
const selector = diffX > 0 ? '.nav-item-next' : '.nav-item-prev';