[Skip to main content](#vessel-content)

#   Show product's category name in product listing

##

- **[ashx88](/forum/user/48374-ashx88 "View ashx88's Profile")**
- [![ashx88's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/48374-ashx88 "View ashx88's Profile") Topic Author
- [ Offline](/forum/user/48374-ashx88)

Less More

- Posts: 28
- Thank you received: 0
-
-

9 years 3 months ago [\#275953](#275953) by [ashx88](/forum/user/48374-ashx88 "View ashx88's Profile")  *[Show product's category name in product listing](/forum/26-product-category-display/891520-show-products-category-name-in-product-listing#275953 "Hi,  I would like to show each product's category name in the product listing page. What is the code that displays the category name?  Thanks!")* was created by *[ashx88](/forum/user/48374-ashx88 "View ashx88's Profile")*

Hi,

I would like to show each product's category name in the product listing page. What is the code that displays the category name?

Thanks!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84OTE1MjAtc2hvdy1wcm9kdWN0LXMtY2F0ZWdvcnktbmFtZS1pbi1wcm9kdWN0LWxpc3Rpbmc/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26402
- Thank you received: 4081
-
- [](http://obsi.dev)
-

9 years 3 months ago [\#275973](#275973) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Show product's category name in product listing](/forum/26-product-category-display/891520-show-products-category-name-in-product-listing#275973 "Hi,  I would like to show each product's category name in the product listing page. What is the code that displays the category name?  Thanks!")*

Hello,

When you create a post in our forum ; please fill the requested elements so our support team will have the required knowledge to be able to answer you with more accuracy.
Thank you for your understanding.

About your request, without knowing your website, the context and the HikaShop version number you're using ; I'm afraid that I can't answer you.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84OTE1MjAtc2hvdy1wcm9kdWN0LXMtY2F0ZWdvcnktbmFtZS1pbi1wcm9kdWN0LWxpc3Rpbmc/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")**
- [![Mohamed Thelji's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar6861.png)](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")
- [ Offline](/forum/user/6861-mohamed-thelji)

Less More

- Posts: 12953
- Thank you received: 1778
-
-
-

9 years 3 months ago [\#276466](#276466) by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")  Replied by *[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")* on topic *[Show product's category name in product listing](/forum/26-product-category-display/891520-show-products-category-name-in-product-listing#276466 "Hi,  I would like to show each product's category name in the product listing page. What is the code that displays the category name?  Thanks!")*

Hello,

> I would like to show each product's category name in the product listing page. What is the code that displays the category name?

I think that you created a new thread to give us more information about what you wanted to do but I erased it by mistake, my bad.

There is no option to display the categories of a product on the listing since usually you have only one category and a listing of products already bases itself on that category to display the products listing so you already know the category of all the products of the listing and they usually are the same.

So you'll indeed need to edit the view file which displays each product in order to load its categories and then display them.
First, to know which view file you need to edit and how you can edit it, I would recommend that you read this:
[ www.hikashop.com/support/documentation/1...-display.html#layout](https://www.hikashop.com/support/documentation/153-customize-the-display.html#layout)
After that, if you're a developer, you should easily find how to get the product_id of the current product, run a MySQL query to load the categories of the product from the database and display that.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84OTE1MjAtc2hvdy1wcm9kdWN0LXMtY2F0ZWdvcnktbmFtZS1pbi1wcm9kdWN0LWxpc3Rpbmc/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[ashx88](/forum/user/48374-ashx88 "View ashx88's Profile")**
- [![ashx88's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/48374-ashx88 "View ashx88's Profile") Topic Author
- [ Offline](/forum/user/48374-ashx88)

Less More

- Posts: 28
- Thank you received: 0
-
-

9 years 3 months ago [\#276537](#276537) by [ashx88](/forum/user/48374-ashx88 "View ashx88's Profile")  Replied by *[ashx88](/forum/user/48374-ashx88 "View ashx88's Profile")* on topic *[Show product's category name in product listing](/forum/26-product-category-display/891520-show-products-category-name-in-product-listing#276537 "Hi,  I would like to show each product's category name in the product listing page. What is the code that displays the category name?  Thanks!")*

Hi,

Thanks for getting back. Previously I enquired on how to display branding of the product at the listing page and was told to add some codes to the listing_img_title view. ([ here](https://www.hikashop.com/forum/product-category-display/891255-displaying-brand-info-in-product-listing-at-category-page.html)) Would it be as simple as that? (Are there pre-written codes that I can just copy and paste to the view file)

Unfortunately, I'm not a developer and do not know how to run a MySQL query or write the codes, they are too complex for me. Would you be able to point me in the right direction? If not, do you do paid customization?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84OTE1MjAtc2hvdy1wcm9kdWN0LXMtY2F0ZWdvcnktbmFtZS1pbi1wcm9kdWN0LWxpc3Rpbmc/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[kyratn](/forum/user/38342-kyratn "View kyratn's Profile")**
- [![kyratn's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/redswirl.jpg)](/forum/user/38342-kyratn "View kyratn's Profile")
- [ Offline](/forum/user/38342-kyratn)

Less More

- Posts: 1119
- Thank you received: 114
-
- [](http://kyra.lt)
-

9 years 3 months ago -  9 years 3 months ago [\#276592](#276592) by [kyratn](/forum/user/38342-kyratn "View kyratn's Profile")  Replied by *[kyratn](/forum/user/38342-kyratn "View kyratn's Profile")* on topic *[Show product's category name in product listing](/forum/26-product-category-display/891520-show-products-category-name-in-product-listing#276592 "Hi,  I would like to show each product's category name in the product listing page. What is the code that displays the category name?  Thanks!")*

Hi,

This should do the job:
Code:

&lt;div class="clearfix related-categories-list"&gt; &lt;?php $q = 'SELECT c.* '. ' FROM ' . hikashop_table('product_category').' as pc '. ' INNER JOIN '.hikashop_table('category').' AS c ON pc.category_id = c.category_id '. ' WHERE pc.product_id = '.$this-&gt;row-&gt;product_id; $database-&gt;setQuery($q); $product_categories = $database-&gt;loadObjectList(); $categories = array(); if($product_categories) foreach ($product_categories as $category) $categories[] = $category-&gt;category_name; if(count($categories) &gt; 2) $categories = array_splice($categories, 0, 2); foreach($categories as $k=&gt;$c){if($k==count($categories)-1) echo '&lt;span class="pull-left margin-reset"&gt;'.$c.'&lt;/span&gt;'; else echo '&lt;span class="pull-left margin-reset"&gt;'.$c.',&lt;/span&gt;';} ?&gt; &lt;/div&gt;

This will display max 2 categories of the product.

If your product is in more then 2 categories then you will have to modify numbers in this line:
Code:

if(count($categories) &gt; 2) $categories = array_splice($categories, 0, 2);

You can add code above based on product view you are using. As example product/listing_img_title

Hope that helps

Kind Regards

Last edit: 9 years 3 months ago by [kyratn](/forum/user/38342-kyratn "View kyratn's Profile").

The following user(s) said Thank You: [Philip](/forum/user/34318-philip "View Philip's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84OTE1MjAtc2hvdy1wcm9kdWN0LXMtY2F0ZWdvcnktbmFtZS1pbi1wcm9kdWN0LWxpc3Rpbmc/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86584
- Thank you received: 14325
-
-

9 years 3 months ago [\#276549](#276549) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Show product's category name in product listing](/forum/26-product-category-display/891520-show-products-category-name-in-product-listing#276549 "Hi,  I would like to show each product's category name in the product listing page. What is the code that displays the category name?  Thanks!")*

Hi,

Well, there is no "pre written" code but the code isn't that complex to write. It will require loading the categories of the product and then echoing it in the view file.
A 3rd party developer should be able to add that for you for a small price if necessary.
You can for example contact our partners:
[ www.hikashop.com/home/our-partners.html](https://www.hikashop.com/home/our-partners.html)

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84OTE1MjAtc2hvdy1wcm9kdWN0LXMtY2F0ZWdvcnktbmFtZS1pbi1wcm9kdWN0LWxpc3Rpbmc/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.056 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
