Answer Summary
Output Woocommerce Brands field in a custom Woocommerce loop:
$args = array('post_type'=>'product','product_cat'=>'cameras');
$loop = new WP_Query( $args );
while ($loop->have_posts()):$loop->the_post();global $product;
// Output our brand name
echo the_terms($loop->post->ID,'product_brand');
Output Custom Text Field for Woocommerce Products and Save on Update
https://gist.github.com/1b0f0ffbeaa38d25cc87139596b1262f
So for a client we were super excited about working with, we did a graphic mockup (they liked) with woocommerce products integrated just so:
No Big Deal. Right? (tldr)
Not having worked with Woocommerce before, I assumed this would be nbd – a simple, “Let’s output our loops with the arguments we want, for a specific category of products in a little slider, and then on the next row, for a list of subcategories of a category of products, ditto for the third and fourth rows with some column classes and custom titles to make everything nice and neat.
Backstory: there were about 250 products we had to migrate from basic wp post type pages to woocommerce product post types. We kept the names which included Brand + Product Name. Then we decided users should be able to sort, filter and see products by brand so we splurged on this bad boy:
Woocommerce Brands Extension: $30 You Wish You Never Spent
A Few Hours Later.. (tldr cont.d)
So now we’ve added a custom field for the brand for each product using the Woocommerce brands extension. But most of our products’ titles have the brand name in them – nature of the video equipment business – and we want to leave it that way.
I have tried about 30 ways to output a custom field for the product name without the brand.
But now we have brand + brand + product name for all of our video cameras. And I’m realizing we need a custom field for product name without the brand name in it.
Remember, this was the goal:
We want to output Brand < br > Product Name for a product category loop of “cameras.” And we don’t want to put the strain on the client to have to enter data in an unusual way or unfamiliar way. So our best bet is to create a custom field for product pages that will go hand in hand with our brands field output, and we can wrap it all in a custom Woocommerce products loop.
Leave a Reply