Function Reference: wlmapi_get_level_categories

Retrieves all categories associated with the specified level.

Parameters

  • level_id (int) – The ID of the level to retrieve categories from

Return

Returns a multi-dimensional array containing data for each category.

Example Code

<?php
     $categories = wlmapi_get_level_categories(1340726008);
     print_r($categories);
?>

Example Output

Array
(
    [success] => 1
    [categories] => Array
        (
            [category] => Array
                (
                    [0] => Array
                        (
                            [ID] => 9
                            [name] => Child Category I
                            [_more_] => /levels/1340726008/categories/9
                        )

                    [1] => Array
                        (
                            [ID] => 10
                            [name] => Child Category II
                            [_more_] => /levels/1340726008/categories/10
                        )

                    [2] => Array
                        (
                            [ID] => 11
                            [name] => Child Category III
                            [_more_] => /levels/1340726008/categories/11
                        )

                    [3] => Array
                        (
                            [ID] => 12
                            [name] => Grandchild Category I
                            [_more_] => /levels/1340726008/categories/12
                        )

                    [4] => Array
                        (
                            [ID] => 6
                            [name] => Parent Category I
                            [_more_] => /levels/1340726008/categories/6
                        )

                    [5] => Array
                        (
                            [ID] => 7
                            [name] => Parent Category II
                            [_more_] => /levels/1340726008/categories/7
                        )

                    [6] => Array
                        (
                            [ID] => 8
                            [name] => Parent Category III
                            [_more_] => /levels/1340726008/categories/8
                        )

                    [7] => Array
                        (
                            [ID] => 1
                            [name] => Uncategorized
                            [_more_] => /levels/1340726008/categories/1
                        )

                )

        )

    [supported_verbs] => Array
        (
            [0] => GET
            [1] => POST
        )

)

Notes

This functions returns WLMAPIMethods::get_level_categories($level_id) in core/api-helper/class-api-methods.php