Skip to content

Instantly share code, notes, and snippets.

View bencicpatricija's full-sized avatar

Patricija bencicpatricija

View GitHub Profile
@bencicpatricija
bencicpatricija / pb-wc-product-category-list-with-child-categories
Created November 7, 2021 12:45
WooCommerce product category list with child categories
<?php
/**
* WooCommerce product category list with child categories
*/
// Function to get top-level "product_cat" terms with their child terms (1 level only).
function pb_get_woocommerce_categories() {
$taxonomy = 'product_cat';
// If you wish to exclude "Uncategorized" term ID, use this function - https://gist.github.com/bencicpatricija/3eec5e8345202c7b06d4838219dff112
@bencicpatricija
bencicpatricija / pb-wc-get-uncategorized-term-id-from-product_cat-taxonomy
Created November 7, 2021 12:36
Get "Uncategoriezed" term ID from "product_cat" taxonomy
/**
* Get "Uncategorized" term ID from "product_cat" taxonomy.
*/
function pb_get_product_uncategorized_term_id() {
$uncategorized_term_id = get_term_by( 'slug', 'uncategorized', 'product_cat')->term_id;
if ( ! class_exists( 'woocommerce' ) || ! $uncategorized_term_id ) {
return false;
} else {
return $uncategorized_term_id;
@bencicpatricija
bencicpatricija / pb-wc-custom-tax-term-in-product-permalink.txt
Last active July 27, 2021 09:36
Woocommerce custom taxonomy term in product base permalink