• phazzed

    (@phazzed)


    Hi all,

    I’m trying to figure out how I can check if a specific child category belongs to a specific parent category.

    Such as is_child(“america”,”country”);

    In other words, is ‘america’ a child to its parent category ‘country’.

    I’ve been stuck for a couple days and cannot find a solution, any help would be appreciated.

    Many thanks,
    Christopher

Viewing 3 replies - 1 through 3 (of 3 total)
  • blogsdna

    (@blogsdna)

    you can use this get_category_parents for finding parent category of specified child category

    Thread Starter phazzed

    (@phazzed)

    Thanks for your reply blogsdna,

    Two things:

    1. When I pass “america”, it’s returning “country”, which is correct, it is also returning “america”, I need it to only display the parent?

    2. It’s passing back the name of the parent, I need it to pass back the ID of the parent category so I can use that in PHP.

    Let me explain, I would like to have an output like this..

    Countries
    America, South Africa, Russia

    Basically showing which children belong to that parent (there will be multiple parents, so I will have to create an array). I also need to then be able to wrap tags around the children and parent, so as to do something like..

    America

    Make sense?

    Hello,

    I need something similar, I hope you can help me.

    I only need to check if the page is a child of parent page “projects”, so that I can display different content.

    How would i do that?

    Thank you ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Is a category child to specific parent’ is closed to new replies.