Skip to content

Instantly share code, notes, and snippets.

View delennerd's full-sized avatar

Pascal Lehnert delennerd

View GitHub Profile
@apsolut
apsolut / giftable-exclude-category-from-shop-archive.php
Created June 24, 2019 23:39
giftable-exclude-category-from-shop-archive
<?php //<- dont add me into functions.php
/**
* Hide Gift Product Category from Shop
* https://wordpress.org/support/topic/hide-gift-product-category-from-shop/
* Create category Exclude or Gifts
* Category slug: exclude, gifts
* add gifts that you want to exclude from shop archive to this category
*/
add_action( 'woocommerce_product_query', 'giftable_custom_pre_get_posts_query' );
@igorbenic
igorbenic / clauses.php
Last active February 21, 2024 21:34
Extending WP_Query with Custom Queries and Tables | https://www.ibenic.com/extending-wp-query-custom-queries-tables
<?php
add_filter( 'posts_clauses', 'filter_clauses', 10, 2 );
/**
* Filtering everything.
*
* @param array $clauses Array with all parts of the query.
* @param WP_Query $wp_query Object.
* @return string
@josanua
josanua / theme-helper.php
Last active June 3, 2024 13:10
Theme Dev Helper
<?php
// General info
https://codex.wordpress.org/Theme_Development
// Core info
https://wp-learner.com/wotdpress-development/wordpress-core-files-and-functions/
// Theme Handbook
https://developer.wordpress.org/themes/
@wpadmin
wpadmin / hide-uncategorized-category.php
Last active December 3, 2021 16:01
WooCommerce 3.3 - Hide uncategorized category from the shop page on the frontend and Remove Categories from WooCommerce Product Category Widget
<?php
/**
* WooCommerce 3.3 - Hide uncategorized category from the shop page on the frontend and Remove Categories from WooCommerce Product Category Widget
*/
add_filter( 'woocommerce_product_subcategories_args', 'krs_remove_uncategorized_category' );
add_filter( 'woocommerce_product_categories_widget_args', 'krs_remove_uncategorized_category' );
add_filter( 'woocommerce_product_categories_widget_dropdown_args', 'krs_remove_uncategorized_category' );
add_filter( 'ywcca_wc_product_categories_widget_args', 'krs_remove_uncategorized_category' );
function krs_remove_uncategorized_category( $args ) {
@fuyuko
fuyuko / functions.php
Last active July 21, 2023 13:06
Cheatsheet - WooCommerce Customization in functions.php
//Add a stylesheet after default style.css
wp_enqueue_style( 'my-css', get_template_directory_uri() . 'my-css.css', array('themename-style'));
//WooCommerce - Sort products by SKU
add_filter('woocommerce_get_catalog_ordering_args', 'custom_woocommerce_catalog_orderby');
function custom_woocommerce_catalog_orderby( $args ) {
$args['meta_key'] = '_sku';
$args['orderby'] = 'meta_value';
$args['order'] = 'asc';
return $args;