Change WooCommerce Tag to Brand

woocommerce logo

If you are looking to tag all your WooCommerce products as brands and want to display them as Brand instead of Tag to make it look more presentable, I’m going to tell you how.

For this demonstration, I use the theme-customizations plugin which allows me to insert additional functions, CSS and other custom code so that it doesn’t get lost in a WooCommerce upgrade. However, you can use your built in theme’s functions.php as well.

  1. Insert the following code as a new function in your functions.php:

add_filter(‘gettext’, ‘translatemywords’);
add_filter(‘ngettext’, ‘translatemywords’);

function translatemywords($translated) {
$translated = str_ireplace(‘Tag:’, ‘Brand:’, $translated);
return $translated;
}

What this code does is change the Tag: string to Brand:

If you need to change multiple words, then you can use something similar to this:

add_filter(‘gettext’, ‘translatemywords’);
add_filter(‘ngettext’, ‘translatemywords’);

function translatemywords($translated) {
$translated = str_ireplace(‘Tag:’, ‘Brand:’, $translated);
$translated = str_ireplace(‘Coupon code’, ‘Promo code’, $translated);
$translated = str_ireplace(‘Quantity’, ‘Qty’, $translated);
return $translated;
}

You can use this code for any application to translate many other strings in WooCommerce. Just make sure to use an additional functions.php or the customizations plugin. Do not edit the core WooCommerce files.

Hopefully this helped translate your Tag to Brand. If you

How To Add Category Thumbnails To Homepage In WordPress

I had to come up with the task of creating category thumbnails for a friend of mine. Here is a snippet of code if you need to use this:

<?php

global $post;
$temp_post = $post;
$args = array(‘numberposts’ => 6, ‘category’ => 227, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’);
echo ‘<div class=”categoryThumbnailList”>’;
$myposts = get_posts($args);
foreach ($myposts as $post) : setup_postdata($post);
if (has_post_thumbnail()) {
$thumbnail = get_the_post_thumbnail($post->ID, ‘thumbnail’);
$link = get_permalink($post->ID);
$title = get_the_title();
echo ‘<div class=”categoryThumbnailList_item”>’;
echo ‘<a href=”‘ .$link . ‘” title=”‘ .$title . ‘”>’ .$thumbnail . ‘</a><br/>’;
echo ‘<a href=”‘ .$link . ‘” title=”‘ .$title . ‘”>’ .$title . ‘</a>’;
echo ‘</div>’;
}
endforeach;
echo ‘</div>’;
echo ‘<div class=”categoryThumbnailList_clearer”></div>’;
$post = $temp_post;
wp_reset_postdata();

?>