Home Forums WC Vendors Free Support Vendor categories on shop page

NOTICE: We've Moved to a Ticket System for Support

As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system.  This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.

For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.

If you are a WC Vendors Pro customer please open a support ticket here. 

If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.

The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.


Thank you to all of our customers!


Viewing 20 posts - 1 through 20 (of 20 total)
  • Author
  • #5852


    This question is in regards to a post in the “feature requests” forums… but I thought it may be more appropriate to create a new topic for this question rather than clutter up the features forum.

    The post has the link to the code changes necessary to show categories on an individual vendor’s shop page. You also included this shortcode: [wcv_vendorslist vendor=”vendors-username” category=”category-slug”]

    This is a function that will be very important for my site and I am glad to see the option to include this.

    However, when I tried to use the gitub selection here: https://github.com/wcvendors/wcvendors/commit/3c9c584fe4bafec34ed14b49e179ae864c511014
    I received the white screen of death.

    I backed up and tried again using the code from this page: https://github.com/wcvendors/wcvendors/blob/3c9c584fe4bafec34ed14b49e179ae864c511014/WCVendors/classes/includes/class-wcv-shortcodes.php
    And also received the white screen of death.

    Now, it is very possible that I am not formatting it correctly… but I was wondering if I am just supposed to copy the “green” highlighted sections on the lines of code? Or do I need to copy the entire page? I see that there are several functions going on there so I might be copying the wrong pieces. I did make sure that the “+” at the beginning of each line was deleted after I pasted the code into my child theme. I was also careful not to double up on the <?php and to add the shown number of } since I know this is important. Other than that I am a total noob with php so I might be royally messing this up.

    I’m specifically needing the function to include categories on the vendor shop pages with only their own items displayed when a category is selected from their shop page. Likely my vendors will have many items and many categories and I’d REALLY like to offer this feature for them in their own shop pages.
    The other functions going on (best selling products, etc.) look nice, too… but it is the categories specifically that I am after.

    Thank you in advance for your assistance.

    WC Vendors Support

    + (green) indicates a line added.

    – (red) indicates a line removed.

    It’s ALWAYS best to just copy the entire file, and overwrite, rather than going line by line unless it’s just something simple like a typo or a syntax fix.

    So, on: https://github.com/wcvendors/wcvendors/commit/3c9c584fe4bafec34ed14b49e179ae864c511014

    Click “View”, then click “Raw”, then copy that and paste it into the existing file.


    Has this been resolved yet?

    Can @ben state what this shortcode really does. Does it create a link list of the current vendor’s? categories.

    – Or –

    it is suppose to show the current vendor’s products in a specified category?

    WC Vendors Support

    The shortcodes work just fine, if you’re having a problem with one, please start a new thread. 🙂


    I should have confirmed that my issue has been resolved.
    It was NOT an issue with the shortcodes; rather I was making errors when trying to use them. I needed to learn how to properly call up the shortcodes. It’s all good now. 🙂

    WC Vendors Support

    The shortcodes are the exact same as the default shortcodes included in WooCommerce, only difference is the vendor argument has been added. Whatever functionality Woo includes for them will be included in these, too. So for what each does, google “WooCommerce Shortcodes” and you’ll see their docs on them.

    Marj Wyatt

    I have not been able to see what this new shortcode outputs, even when I hardcode the vendor username and the product category. So, like tafmakura above, I am asking what, exactly, does this shortcode do?

    I already have written a lot of custom code for the shop headers to extract additional information from the vendor profile for things like business address, a map to their location, and social media connections. On registration, this is gathered through a lengthy Gravity Form and, when on product archives (default template) or single product pages, this vendor header shows.

    My goal is to add a list of product categories in which this vendor has listed products for sale, with counts, similar to a shop page at Etsy. I want this information in the shop header.

    That code is:
    $vendor_shop = urldecode( get_query_var( ‘vendor_shop’ ) );
    $vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
    $key1 = ‘pv_shop_name’;
    $key2 = ‘pv_shop_description’;
    $single = true;
    $shop_name = get_user_meta( $vendor_id, $key1, $single );
    $shop_description = get_user_meta( $vendor_id, $key2, $single );
    $products = get_posts( array(‘post_type’ => ‘product’, ‘posts_per_page’ => -1, ‘author’ => $vendor_id) );
    if ( $vendor_id ) {
    echo ‘<div class=”wcv-wrap”>’;
    echo ‘<div class=”vm-max-1160″>’;
    echo ‘<h1>’ . $shop_name . ‘</h1>’;
    echo ‘</div><!–end vm-max-1160–>’;
    echo ‘<hr>’;
    echo ‘<div class=”clear”>’;
    echo ‘</div><!–end clear–>’;
    echo ‘<div class=”vm-max-1160″>’;
    echo ‘<div class=”wcv-shop-description one-third first”>’;
    echo wpautop( $shop_description );
    echo ‘</div><!– end wcv-shop-description one-third first–>’;
    echo ‘<div class=”one-third”>’;
    get_sidebar( ‘VendorShop’ );
    echo ‘</div><!–end one-third–>’;
    echo ‘<div class=”one-third last”>’;
    get_sidebar( ‘VendorBlock’ );
    echo ‘</div><!–end one-third–>’;
    echo ‘<div class=”clear”>’;
    echo ‘</div><!– end clear –>’;

    /* Experimental Code to List WooCommerce Categories*/
    echo ‘<h4>All categories in our shop:</h4>’;
    get_template_part( ‘content’, ‘product-vendor-cat-list’ );
    echo ‘</div><!–end vm-max-1160–>’;
    echo ‘</div><!–End wcv-wrap–>’;

    My code is working perfectly in product archives and on single products.

    This code is what is in the content-product-vendor-cat-list and it does produce a list of categories with item counts where I’ve placed it in the vendor header, albeit not yet styled for final release:
    /* List WooCommerce product Categories
    Ref links:
    $args = array(
    ‘number’ => $number,
    ‘orderby’ => $orderby,
    ‘order’ => $order,
    ‘hide_empty’ => 1,
    ‘include’ => $ids,
    ‘fields’ => ‘all’,
    ‘exclude’ => array (’26’)

    $product_categories = get_terms( ‘product_cat’, $args );

    $count = count($product_categories);
    if ( $count > 0 ){
    echo “


    I quickly realized that, when a visitor/shopper clicked one of those links, they would be taken to a category archive listing ALL products in that category and not be held captive them at the Vendor’s shop. So, as it stands, it will not do what is desired by my client.

    After that realization, I hit the search engines and found this thread. In hopes that it would save me some head banging, I implemented the new shortcode in your plugin by replacing the existing code in classes/includes/class-wcv-shortcodes.php with the raw code at Github.

    Your new shortcode seems to call for a Vendor Name and seems to require the shop category. When I could not see any output from it in the vendor header, I took this code onto a page and pasted the shortcode there, and published.

    [wcv_vendorslist vendor=”ScooterGuy” category=”home-goods”]

    The resulting page is blank …

    This function is declared in your plugin’s classes/class-vendor.php and it seems like it would assist me in accomplishing the desired goal but it looks like it would only work once a single product is identified in the loop.

    public static function get_vendor_from_product( $product_id )
    // Make sure we are returning an author for products or product variations only
    if ( ‘product’ === get_post_type( $product_id ) || ‘product_variation’ === get_post_type( $product_id ) ) {
    $parent = get_post_ancestors( $product_id );
    if ( $parent ) $product_id = $parent[ 0 ];
    $post = get_post( $product_id );
    $author = $post ? $post->post_author : 1;
    $author = apply_filters( ‘pv_product_author’, $author, $product_id );
    } else {
    $author = -1;
    return $author;

    Perhaps, I’ve gone overboard in my write-up here but I wanted you to see every part of the puzzle so I could get a qualified response.

    Thanks, in advance, for your attention.

    WC Vendors Support

    Unrelated, but:

    $key1 = ‘pv_shop_name’;
    $key2 = ‘pv_shop_description’;
    $shop_name = get_user_meta( $vendor_id, $key1, $single );
    $shop_description = get_user_meta( $vendor_id, $key2, $single );

    could be:

    $shop_name = get_user_meta( $vendor_id, ‘pv_shop_name’, true);
    $shop_description = get_user_meta( $vendor_id, ‘pv_shop_description’, true);

    (saves two lines of code)

    Now onto the wcv_vendorslist shortcode and the arguments you’ve supplied:

    Adding “category=’categoryname'” to the wcv_vendorslist code won’t work. The shortcodes we use, support all of the default WooCommerce attributes. Category display is not one of the included attributes. You could copy the shortcode PHP we use, and add in your own arguments of course, and call it something like wcv_vendorslistwithcats or whatever you choose of course!

    The code for wcv_vendorslist his here:


    To create your own shortcode, simply copy line # 34 and rename the shortcode and the function, and then copy line #546-630. You can then add in, or even remove, any arguments you like and voila! You have your own new custom shortcode. Add the new code to your themes functions.php file and you wont have to edit any of the WC Vendors plugin code.



    Marj Wyatt

    Hey Ben,

    Thank you for your thoughtful reply. I’ll lose the extra 2 lines of code, per your suggestion. Part of what is in my code now is from a subcontractor who threw their development over the wall on August 23, 2015, unfinished, and supplied no documentation about your plugin other than a reference to the fact that it was required. I was relieved to see that you folks supply good documentation for your plugin. Thank you for that. 🙂

    I’ll try the method you’ve recommended just now in your reply and get back to you. I’ll return to let you know how that goes.

    Please do tell me, does your new shortcode have to be within the loop to work? The archive-product.php template is already displaying only the products offered by the vendor whose shop is in the header.

    Since my vendor header code executes above the loop, I’m not sure if I have to pre_get_posts and isolate the products posted by the shop vendor before I go after the terms and counts for items within those terms, which is all I want to display with the active link. I got this idea from looking at an Etsy shop.

    Perhaps, I’m over-complicating this.

    WC Vendors Support

    The wcv_vendorslist code can be used anywhere. I’ve seen some members here convert it into a sidebar widget, too. 🙂 It doesnt have to be within the loop (I dont think, anyway).

    We’re always here for support. We understand fully that a plugin like ours requires it, and that we shall provide. 🙂



    Marj Wyatt

    I just got a look at what this shortcode does.


    That is not what I’m trying to do. I’m trying to list product categories for a specific vendor in the header of their shop archives and/or on their single products pages.

    If your shortcode does not do this, I’ll quit messing around with it and focus on another way.

    My preference, actually, would be to not use a shortcode to do this and that was the tack that I was on when I found this thread.

    WC Vendors Support

    Querying WordPress for categories for products is a very expensive query resource-wise. That’s why WooCommerce does not include it in the plugin. You would essentially have to write it yourself. I would suggest caching the results for page speed improvements if you do!

    Marj Wyatt

    The idea is to keep visitors/shoppers inside a vendor shop when they get there, like this shop at etsy

    WC Vendors Support

    Yup, and with WC Vendors Pro, we’ll have features like that. 🙂

    Marj Wyatt

    I do see a discussion topic in your form regarding WC Vendors Pro. It’s probably a big development and a good move for you folks.

    I also see that there is no firm release date for your pro version. Is the functionality there yet? Do you want beta testers? 🙂

    WC Vendors Support

    Nope, no beta testers. 🙂 It’ll be released very soon. October 1st! 🙂

    Marj Wyatt

    Hey Ben,

    You sound excited and, while I don’t know you well and haven’t been here long, it seems that you should be. It is good to know that the Pro version is so near at hand.

    Of course, with the level of coding effort that I’ve invested in creating a vendor header that displays in a 3-column layout including many custom user meta fields collected via a Gravity Form, switching over to a premium version of your plugin may present more problems than it solves so I would want to preview functionality on Xampp before rolling it into this development. If my client decides to buy the Pro version, I hope the fees associated with your new software allows usage for unlimited sites.

    One thing I wanted to offer with regard to the topic of this thread is that the shortcode we’ve been discussing should offer an option to upload a profile image/logo for their shop rather than forcing the use of an Avatar from WordPress. At least this is my opinion.

    WC Vendors Support

    Thanks, we are indeed very excited! The license for Pro is $99 for one site. We’ll have a multi site package, but it will not be unlimited sites. This plugin is way too niche specific than to be able to give it away like they do with themes and big plugins like Gravity Forms.

    The images to be used on the headers/cover/avatar on the Pro version, are not going to require a WordPress avatar. They are all uploaded from the Vendor Dashboard. 🙂

    Marj Wyatt

    So, will I need to have a separate license to use it on Xampp locally?

    WC Vendors Support

    No, you will be fine using it locally. 🙂

Viewing 20 posts - 1 through 20 (of 20 total)
  • The forum ‘WC Vendors Free Support’ is closed to new topics and replies.