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

  • SEARCH
  • Home
  • 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 6616723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:37:02+00:00 2026-05-25T20:37:02+00:00

I have one category named City and Second category Named Decease Inside City different

  • 0

I have one category named City and Second category Named Decease Inside City different cities will be there and inside Decease different decease will be there.

I will have posts having one city and more than one decease.

So what I want is when I click on One City I want to show all the decease belonging to this category.

So In detail with one city suppose 4 posts are there and all posts belongs to some decease So I need to find that how many posts are there having one category as this city. And then I need to find All the categories of all these posts and from that I need to find which categories parent category name is Decease. And then I need to show those categories.

How I should code this in wordpress in a nice manner? If some one has already spend some time on doing like this code then Kindly guide what will be good way to do this.

  • 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-05-25T20:37:03+00:00Added an answer on May 25, 2026 at 8:37 pm
    $deseace_cat_id = getCareTypeCategoryId(); 
        $careType=array();
        if(have_posts())
        {
            $cats = array();
            $cat_ids=array();                           
    
             while (have_posts()) : the_post();
                $post_categories = wp_get_post_categories( $post->ID );
                foreach($post_categories as $c){                
                    $cat = get_category( $c );
                    if(!in_array($c, $cat_ids) && $cat->category_parent==$deseace_cat_id)
                    {
                        $cat_ids[]=$c;          
                        $cats[] = array( 'name' => $cat->name, 'slug' => $cat->slug );                          
                    }               
                }                                                           
                echo "<br>";
             endwhile;
             for($i=0;$i<count($cats);$i++)
             {
                ?>
                <a class="careTypeUrl" href="#" careSlug='<?php echo $cats[$i]['slug'];?>'><?php echo $cats[$i]['name'];?></a><br>
                <?php   
             }       
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one model User and will be creating another one Category . Both
I have a page set up to show only posts from one category, which
Problem: I have two array where one produce a category and the second produce
I have a simple Crud application where there is one filed called Category. During
I have one of simple DB tables named category: category.id category.name category.lang 1 'apple'
I have two JSF <h:selectOneMenu> components. One called category another is subcategory . If
I have some Javascript code that creates 2 arrays: One for Product Category and
I have sql statement one; select linkscat.id, linkscat.category from linkscat, contentlinks, links where contentlinks.linksid
I have these types of urls: /city/ /city/category/ /city/category/subcategory/ All of the urls are
I have a orders table that have order detail and the column named Category

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.