Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8126415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:08:25+00:00 2026-06-06T07:08:25+00:00

I have 7 Categories (parents), and every category has 15 sub-categories. When I select

  • 0

I have 7 Categories (parents), and every category has 15 sub-categories.

When I select some category (parent), I want to display only sub-categories (children) of that particular parent category (parent).

After I click on sub-category (child) then it should display its posts only.

I have a fron_page.php and category.php.

How can I write this to first show sub-categories separately, then post of that sub-category separately in new file, which user want to see.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T07:08:27+00:00Added an answer on June 6, 2026 at 7:08 am

    This code should help you:

    <ul> 
    <?php 
     $cats = get_the_category();
     $mycat = $cats->cat_ID;
        wp_list_categories('orderby=id&child_of='.$mycat); 
    ?>
    </ul>
    

    OR

    <?php
    if (is_category()) {
        $cat = get_query_var('cat');
        $this_category = get_category($cat);
        $this_category = wp_list_categories('hide_empty=0&hierarchical=true&orderby=id&show_count=0&title_li=&use_desc_for_title=1&child_of='.$this_category->cat_ID."&echo=0");
        if($this_category !='<li>No categories</li>')
        {
         echo '<ul>'.$this_category.'</ul>'; 
        }
    }
    ?>
    

    Let me know please.

    Good luck! 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Categories table in which each category has a ParentId that can
I have a site with categories and topics. Some categories are parents/children of each
I have a navigation with hidden sub menus that display when ever their parent
I have main categories and sub categories. I want to be able to sort
Say I have some 10 categories that I need to reference in a web
I have a categories table Category [ID, Title] and a Parent/Child table CategoryParent [ID,CategoryID,ParentCategoryID]
I have a hierarchy of categories, where a category can have a single parent
I want to create a Category class that may or may not have a
I have a products table that contains a FK for a category, the Categories
I have this table. I want to select cat id = 4 and every

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.