I was hoping somebody could help me out with custom fields.

I created a custom post type called game-type in WordPress. In this I have the categories "Android", "iOS" and "PC", then within these I have categories for types of games "3D Action", "Classics", "Platform" etc.

So an example hierarchy for each post works like this: Games > Android > 3D Action > Post (Game)

So far I've managed to call a list of categories using the code:


$taxonomy     = 'game-type';
$orderby      = 'name';
$show_count   = 0;      // 1 for yes, 0 for no
$pad_counts   = 0;      // 1 for yes, 0 for no
$hierarchical = 1;      // 1 for yes, 0 for no
$title        = '';

$args = array(
 'taxonomy'     => $taxonomy,
 'orderby'      => $orderby,
 'show_count'   => $show_count,
 'pad_counts'   => $pad_counts,
 'hierarchical' => $hierarchical,
 'title_li'     => $title

<?php wp_list_categories( $args ); ?>

But this lists all the categories in my custom field. Is there a way to target just the categories in "android"?

Your help would be much appreciated.


Site: http://www.sugartree.org.uk/company

2 Answers 2


Have you tried using include/exclude?

$taxonomy     = 'game-type';...
$include      = 'ANDROID ID IE: 1'

    $args = array(...
        include           => $include

EDIT: vancoder is right: it should be...

   $taxonomy     = 'game-type';...
    $child_of= 'ANDROID ID IE: 1'

        $args = array(...
            child_of    => $child_of

Where $child_of is the ID of your subcategory.

  • Brandon = the include seems to be getting somewhere but it's cutting out the child categories and just leaving a link to Android. I may have written it wrong, I've put: $include = '4&post_type=games';... 'include' => $include,
    – user27833
    Commented Feb 21, 2013 at 21:25
  • @user27833 user ` for code or edit original question. You also may need a mixture of mine and vancoder's solution. (PS. it's Bandon)
    – Brooke.
    Commented Feb 21, 2013 at 21:27
  • I've tried $child_of = '4&post_type=games'; and $child_of = 'ANDROID ID IE: 1'; They both deliver 'No categories' am I writing the ID wrong?
    – user27833
    Commented Feb 21, 2013 at 21:47
  • Maybe, It should be the ID of the Android category. It looks like you have missing quotes. meaning it should be child_of = 4&taxonomy=game-type post_type is not allowed as an accepted argument of wp_list_categories
    – Brooke.
    Commented Feb 21, 2013 at 21:52
  • That's still delivering 'no categories' the full ID from looking at categories (which is how i'd usually find the ID is : /edit-tags.php?action=edit&taxonomy=game-type&tag_ID=4&post_type=games
    – user27833
    Commented Feb 21, 2013 at 22:11


child_of => [id for android]

to your args.

  • Would I write it like this? 'child_of' => [4&post_type=games], It's not sending me anything back.
    – user27833
    Commented Feb 21, 2013 at 21:31
  • 1
    Please see example below.
    – vancoder
    Commented Feb 21, 2013 at 21:43
  • I solved it. I just need the number from the ID, that's it: $child_of = '4'
    – user27833
    Commented Feb 25, 2013 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.