Skip to content

Instantly share code, notes, and snippets.

@goliver79
goliver79 / functions.php
Last active August 29, 2015 13:56
[WOOCOMMERCE] Show empty categories
<?php
// WooCommerce Code
// Show empty categories
// https://gist.github.com/renegadesk/3926139
// https://gist.github.com/dalemoore
add_filter('woocommerce_product_subcategories_args', 'woocommerce_show_empty_categories');
function woocommerce_show_empty_categories( $cat_args ){
$cat_args[ 'hide_empty' ] = 0;
return $cat_args;
}
@goliver79
goliver79 / sql.vb
Last active August 29, 2015 13:56
[MSACCESS] Database Query and Recordset
Dim db As Database
Dim rs As Recordset
Dim sql As String
Dim id as Integer
id = 20
sql = "SELECT * FROM MyTable " & _
"WHERE id = " & id
Set db = CurrentDb
Set rs = db.OpenRecordset(sql)
@goliver79
goliver79 / functions.php
Last active August 29, 2015 13:56
[WOOCOMMERCE] Shop pages limited view
<?php
// only some users can view shop pages
add_action( 'template_redirect', 'check_user_view' );
function check_user_view(){
if( is_some_shop_page() ){
// we are in some woocomerce (shop) page
if( !( user_can_view_shop() ) ){
wp_redirect( get_home_url() );
}
}
@goliver79
goliver79 / functions.php
Created February 5, 2014 14:01
[WOOCOMMERCE] Change "Random Products" Widget Title
<?php
/*
* Change "Random Products" widget title
*/
add_filter( 'widget_title', 'woo_widget_title', 10, 3);
function woo_widget_title( $title, $instance, $id_base ) {
if( 'woocommerce_random_products' == $id_base) {
return __( "My New SuperTitle", 'my_text_domain' );
}
}
@goliver79
goliver79 / functions.php
Last active December 6, 2017 04:12
[WOOCOMMERCE] Add Product Categories to the "Product" Breadcrumb
<?php
// Add product categories to the "Product" breadcrumb in WooCommerce.
// Get breadcrumbs on product pages that read: Home > Shop > Product category > Product Name
/*
* CAUTION: if a product is in more than one category, only show the first found category.
*/
add_filter( 'woo_breadcrumbs_trail', 'woo_custom_breadcrumbs_trail_add_product_categories', 20 );
function woo_custom_breadcrumbs_trail_add_product_categories ( $trail ) {
if ( ( get_post_type() == 'product' ) && is_singular() ) {
global $post;
@goliver79
goliver79 / functions.php
Created February 5, 2014 14:07
[WORDPRESS] Login redirecto to index
<?php
/*
* login redirect to index (all users)
*/
add_filter( 'login_redirect', 'my_login_redirect' );
function my_login_redirect(){
return site_url();
}
/*
@goliver79
goliver79 / functions.php
Created February 5, 2014 14:10
[WOOCOMMERCE] Get thumbnail without resize
<?php
/*
* @goliver: overwrite function for get thumbnail without resize
* original in woocommerce-template.php
*/
function woocommerce_get_product_thumbnail( $size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0 ) {
global $post;
if ( has_post_thumbnail() )
return get_the_post_thumbnail( $post->ID );
@goliver79
goliver79 / functions.php
Last active September 7, 2015 18:10
[WOOCOMMERCE] Get category thumbnail without resize
<?php
/*
* @goliver: overwrite function for get category thumbnail size without resize
* original in woocommerce-template.php
*/
function woocommerce_subcategory_thumbnail( $category ) {
global $woocommerce;
$small_thumbnail_size = apply_filters( 'single_product_small_thumbnail_size', 'shop_catalog' );
$dimensions = $woocommerce->get_image_size( $small_thumbnail_size );
@goliver79
goliver79 / functions.php
Created February 5, 2014 14:13
[WOOCOMMERCE] Not show star rating in shop loop
<?php
/*
* @goliver: remove hook woocommerce_template_loop_rating for not displaying rating in
* shop loop
*/
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5);
@goliver79
goliver79 / functions.php
Created February 5, 2014 14:16
[WOOCOMMERCE] Remove "You are here" from breadcrumb
<?php
/**
* remove "You are here" from breadcrumb
*/
add_filter('woo_breadcrumbs_args','lgpd_breadcrumb_args_filter');
function lgpd_breadcrumb_args_filter( $args ){
$args[ 'before' ] = '';
return $args;
}