Completed

Need code to get woocommerce top level parent category title

This project was successfully completed by anshulmahajan89 for $34 USD in a day.

Get free quotes for a project like this
Employer working
Completed by:
Skills Required
Project Budget
$10 - $30 USD
Completed In
1 day
Total Bids
5
Project Description

Im using a custom theme and creating a custom template for woocommerce categories and single product pages.

Im trying to figure out the code to show the top level parent category title on sub category pages. In my design I need to show the current category being viewed and the top parent category title.

If Im viewing Category 1 > sub cat 1 > sub cat 2 then I would like to display two titles on this category page - Category 1 and sub cat 2

If Im viewing a product inside sub cat 2, I want to still see the current category (sub cat 2) and the top level parent (Category 1).

If you look at the image attached you will see that basically the bread crumb it spit up into three titles on my page.

I just need the snippet of code that I can place in my theme to show the top level parent category title on my category and single product pages. It should only show the top level title even if there are multiple sub parents such as cat 1 > cat 2 > cat 3 > cat 4 ---- when viewing cat 4 I will see cat 1 and cat 4 titles.

You will need to know how to do this, Ive spent a week in the forums with no success but I know it can be done because its easy to do with normal wordpress categories.

Looking to make some money?

  • Set your budget and the timeframe
  • Outline your proposal
  • Get paid for your work

Hire Freelancers who also bid on this project

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online