Skip to content

Instantly share code, notes, and snippets.

View gmmedia's full-sized avatar

Jochen Gererstorfer gmmedia

View GitHub Profile
@gmmedia
gmmedia / main-collection-product-grid.liquid
Created August 24, 2025 13:42
Shopify jsonld for Collections
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "CollectionPage",
"name": {{ collection.title | json }},
"url": "{{ shop.url }}{{ collection.url }}",
"description": {{ collection.description | strip_html | truncate: 300 | json }},
"mainEntity": {
"@type": "ItemList",
"name": {{ collection.title | json }},
@gmmedia
gmmedia / functions.php
Created May 2, 2025 08:02
WooCommerce Category Widget Legacy
/* Make Category sidebar 90% viewport height - 220px header size */
/*.woocommerce.widget_product_categories ul.product-categories {
max-height: calc(-220px + 90vh);
overflow: auto;
}
.woocommerce.widget_product_categories ul.product-categories li.cat-item {
list-style: none;
}
.woocommerce.widget_product_categories ul.product-categories li.cat-item a {
list-style: none;
@gmmedia
gmmedia / style.css
Created April 10, 2025 22:39
Horizontal lists with grid
/* Horizontal grid for lists and text. */
.list-grid {
display: grid;
grid-template-columns: repeat(auto-fit,minmax(132px, 1fr));
}
/* Horizontal grid for lists and text with a | devider. */
ul.list-grid-divider {
display: grid;
grid-template-columns: repeat(auto-fit,minmax(132px, 1fr));
list-style-type: none;
@gmmedia
gmmedia / style.css
Created April 10, 2025 22:38
Horizontal lists with flex
/* Horizontal flex for lists and text. */
.list-flex {
display: flex;
justify-content: space-around;
}
.list-flex li {
flex-grow: 1;
}
/* Horizontal flex for lists and text with a | devider. */
.list-flex-divider {
@gmmedia
gmmedia / functions.php
Last active February 2, 2025 05:16
Add alt tag to WordPress Gravatar images
<?php
// Add alt tag to WordPress Gravatar images
// Full how-to: https://bloggerpilot.com/gravatar-alt-tag/
function bloggerpilot_gravatar_alt($bloggerpilotGravatar) {
if (have_comments()) {
$alt = get_comment_author();
}
else {
$alt = get_the_author_meta('display_name');
function j0e_imagetoRSS($content) {
if (has_post_thumbnail()) {
$feedlink = esc_url(apply_filters('the_permalink_rss', get_permalink()));
$content = '<a href="' . $feedlink . '" rel="nofollow ugc">' . get_the_post_thumbnail(get_the_ID(), 'thumbnail', array('style' => 'float: left; margin: 0 10px 10px 0;')) . '</a>' . $content;
}
return $content;
}
@gmmedia
gmmedia / functions.php
Last active December 7, 2024 02:00
Add featured image column to WP admin panel - posts AND pages
<?php
/**
* Add featured image column to WP admin panel - posts AND pages
* See: https://bloggerpilot.com/featured-image-admin/
*/
// Set thumbnail size
add_image_size( 'j0e_admin-featured-image', 60, 60, false );
<?php
/**
* Removes WooCommerce scripts and styles from non-WooCommerce pages,
* excluding specific pages by post ID.
*/
add_action('wp_print_scripts', 'my_remove_woo_assets', 999);
add_action('wp_enqueue_scripts', 'my_remove_woo_assets', 999);
@gmmedia
gmmedia / functions.php
Last active January 17, 2024 13:56
Enable Gutenberg editor for WooCommerce
<?php
// Find the description at https://bloggerpilot.com/en/gutenberg-for-woocommerce/
// Disable new WooCommerce product template (from Version 7.7.0)
function bp_reset_product_template($post_type_args) {
if (array_key_exists('template', $post_type_args)) {
unset($post_type_args['template']);
}
return $post_type_args;
}
@gmmedia
gmmedia / functions.php
Last active August 13, 2023 14:18
Shortcode: CategoryPosts - Content Hub
<?php
// WordPress Shortcode - Content Hub: Lists all posts for the first category of a post
// Need help: https://bloggerpilot.com/en/content-hub-wordpress/
function bp_categoryposts() {
// Get first category
$categories = get_the_category();
if ( ! empty( $categories ) ) {