How to List Categories and Child categories by current logged in Author

Question

I have created a site where all members are authors and is like a task managements system.

  1. Category -> Clients

  2. Child Category – > Brands

So when a user/author is logged in i want he to see his tasks ( categories ) and child categories.

My code is displaying the categories as i want to be like a list, but i dont know how to make to be displayed for each author.

My Categories / Child categories etc.

<ul class="clients">
                    <?php
        
                    $clients = get_categories(array('parent' => 0,"hide_empty" => 0)); // get top level categories only
        
                    foreach ($clients as $client) {
                        echo '<li><a href=" ' . get_category_link( $client->cat_ID ) . ' ">' . $client->name . '</a>';
        
                        $brands = get_categories(array('parent' => $client->cat_ID)); // get children of parent category
                        echo '<ul class="brands">';
                        foreach ($brands as $brand) {
                            echo '<li><a href=" ' . get_category_link($brand->cat_ID) . ' ">' . $brand->name . '</a>';
                            
                            $projects = get_categories(array('parent' => $brand->cat_ID)); // get children of parent category
                            echo '<ul class="projects">';
                            foreach ($projects as $project) {
                                echo '<li class="project"> <div data-url="'.get_category_link($project->cat_ID).'" data-cat="'.$project->cat_ID .'">' . $project->name . '</div></li>';
                            }
                            
                            echo '</ul></li>';
                        }
                        echo '</ul></li>';
                    } // end of categories logic 
                    
                    ?>
                </ul>
0
FunkyCss 2 years 2021-01-01T12:10:23-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse