0

i have create a page template and Post Type games with taxonomies "gamecategory" but whenever i'm trying to get the categories from gamecategory it is showing that it is an invalid taxonomy.

Here's the code

    $categories = get_terms("taxonomy=gamecategory");
    foreach ($categories as $category) :
        echo '<button class="button" data-filter=".' . $category->slug . '">' . $category->name . '</button>';
    endforeach
Ali
  • 231
  • 1
  • 4
  • 17

1 Answers1

1

it's because:

$categories = get_terms("taxonomy=gamecategory");

Should be:

$categories = get_terms("gamecategory");

Also make sure that, you have created the taxonomy properly. Check more on Codex.

The Alpha
  • 143,660
  • 29
  • 287
  • 307
  • Tried it but not working The above code which i have written is working fine on local host but not on the live site – Ali Jun 01 '14 at 05:57
  • Make sure it exists and also check the link for more details :-) – The Alpha Jun 01 '14 at 05:58
  • It exists and i'm pretty sure about it as I'm retrieving posts for post type games and with each post its taxonomy slug it is giving me right answers – Ali Jun 01 '14 at 06:00
  • Can you try same for `category` instead of `gamecategory` and see if that works ? – The Alpha Jun 01 '14 at 06:03
  • Is that only `game` ? – The Alpha Jun 01 '14 at 06:04
  • tried this on local host . When i attached category to the post type games it was removed from default post type post and attached to post type games – Ali Jun 01 '14 at 06:08
  • yeah this is only games. I have tried the above mentioned trich of category. but it removes categories from default post type post. and adds this to games – Ali Jun 01 '14 at 06:11