Back to Top

How to get all child categories in PHP?

To get all child categories in php

Hi All, sometimes you’re working with eCommerce site and you want to get all subcategories including all level of childs like,


category
    sub-category1
    sub-category2
        sub-sub-category1
        sub-sub-category2
    sub-category3

So, Here I am going to explain how to get all child categories in PHP. In the following function, I have recursively called function to get all level child categories.



That’s it. You can use above function where you require.

Suggested Read:

To create Zoho leads using PHP
To convert PHP array into Javascript array
To grab content from nested tags in PHP

Hope this helps someone else out.As always, thanks for reading. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Comments (2)

  1. Fatal error: Call to undefined function getCategoryTreeForParent()

    1. Where did you put this function?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

What is Press This in WordPress

Posted on 7 years ago

Bhumi

How to use IndexedDB in HTML5

Posted on 3 years ago

Bhumi

How to use Namespace in PHP

Posted on 7 years ago

Bhumi

The Reader’s Poll – June 2015

Posted on 3 years ago

Bhumi

The Reader’s Poll – August 2014

Posted on 4 years ago

Bhumi

The Reader’s Poll – June 2014

Posted on 4 years ago

Bhumi

The Readers’ Poll – May 2014

Posted on 5 years ago

Bhumi

The Readers’ Poll – August 2013

Posted on 5 years ago

Bhumi