Maintaining a WordPress site that has WP Commerce set up installed, I needed to do some minor customisations to a widget that displayed nested Category names. Because some categories shared identical names as other categories of the same level (e.g. ‘Necklaces > Classic’ and ‘Earrings > Classic’), I needed to prepend the parent category name to a menu link to the category that I was creating.
As this information was not readily available on the Internet, I had fiddled around with the WP commerce source.
If you have the current category in a data object, this is perfect. So to retrieve the parent category from a category data object in WPCommerce, simply do:
$parent = get_term((int) $cat->parent, 'product_cat' );
echo $parent->name;
You should then be able to access the parent category in a data object so then you’re free to access it’s properties accordingly.
I have been fortunate in working a lot more with Kubernetes lately over the last few months so I've been…
Building my portfolio site, I thought I'd show you how I set up my Wordpress development using Docker. Given the…
Frustrated with getting blank images in Puppeteer Chrome screenshots, recently I was in a situation where I needed to migrate…
It has been six year since my last major revamp/redesign of my current petertran.com.au portfolio site. So what are my…
This article helps to solve a Bad owner or permissions on .ssh/config issue occurring on a Windows 10 machine when…
Only a few lines of code required is to implement a payment system, thanks to inline Pin Payments integration. Accepting…