CINXE.COM
Function Reference/get taxonomies « WordPress Codex
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <!-- <meta property="fb:page_id" content="6427302910" /> --> <link href="https://plus.google.com/107188080561309681193" rel="publisher"/> <meta name="google-site-verification" content="7VWES_-rcHBcmaQis9mSYamPfNwE03f4vyTj4pfuAw0"/> <meta http-equiv="Content-Style-Type" content="text/css"/> <meta name="generator" content="MediaWiki 1.15.5"/> <meta name="keywords" content="Function Reference/get taxonomies,Function Reference,How to Pass Tag Parameters,Template Tags"/> <link rel="shortcut icon" href="/web/20121024130027im_/http://codex.wordpress.org/favicon.ico"/> <link rel="search" type="application/opensearchdescription+xml" href="/web/20121024130027/http://codex.wordpress.org/opensearch_desc.php" title="Codex (en)"/> <link rel="alternate" type="application/rss+xml" title="Codex RSS feed" href="/web/20121024130027/http://codex.wordpress.org/index.php?title=Special:RecentChanges&feed=rss"/> <link rel="alternate" type="application/atom+xml" title="Codex Atom feed" href="/web/20121024130027/http://codex.wordpress.org/index.php?title=Special:RecentChanges&feed=atom"/> <script type="text/javascript" src="/_static/js/bundle-playback.js?v=HxkREWBo" charset="utf-8"></script> <script type="text/javascript" src="/_static/js/wombat.js?v=txqj7nKC" charset="utf-8"></script> <script>window.RufflePlayer=window.RufflePlayer||{};window.RufflePlayer.config={"autoplay":"on","unmuteOverlay":"hidden"};</script> <script type="text/javascript" src="/_static/js/ruffle/ruffle.js"></script> <script type="text/javascript"> __wm.init("https://web.archive.org/web"); __wm.wombat("http://codex.wordpress.org/Function_Reference/get_taxonomies","20121024130027","https://web.archive.org/","web","/_static/", "1351083627"); </script> <link rel="stylesheet" type="text/css" href="/_static/css/banner-styles.css?v=S1zqJCYt" /> <link rel="stylesheet" type="text/css" href="/_static/css/iconochive.css?v=3PDvdIFv" /> <!-- End Wayback Rewrite JS Include --> <title>Function Reference/get taxonomies « WordPress Codex</title> <link rel="stylesheet" href="//web.archive.org/web/20121024130027cs_/http://wordpress.org/style/codex-wp4.css?3"/> <link rel="stylesheet" href="//web.archive.org/web/20121024130027cs_/http://wordpress.org/style/wp4.css?26"/> <link media="only screen and (max-device-width: 480px)" href="//web.archive.org/web/20121024130027cs_/http://wordpress.org/style/iphone.css" type="text/css" rel="stylesheet"/> <link rel="shortcut icon" href="//web.archive.org/web/20121024130027im_/http://wordpress.org/favicon.ico?3" type="image/x-icon"/> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://web.archive.org/web/20121024130027/https://ssl." : "https://web.archive.org/web/20121024130027/http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> var pageTracker = _gat._getTracker("UA-52447-1"); pageTracker._initData(); pageTracker._trackPageview(); function recordOutboundLink(link, category, action) { pageTracker._trackEvent(category, action); setTimeout('document.location = "' + link.href + '"', 100); } </script> <!--[if lt IE 8]> <style type="text/css"> @import url("//wordpress.org/style/ie.css"); </style> <![endif]--> <script type="text/javascript" src="//web.archive.org/web/20121024130027js_/http://wordpress.org/wp-includes/js/jquery/jquery.js"></script> <script>document.cookie='devicePixelRatio='+((window.devicePixelRatio === undefined) ? 1 : window.devicePixelRatio)+'; path=/';</script> <!--[if IE]> <script type="text/javascript" src="/skins/common/IEFixes.js"></script> <meta http-equiv="imagetoolbar" content="no" /> <![endif]--> <script type="text/javascript" src="/web/20121024130027js_/http://codex.wordpress.org/index.php?title=-&action=raw&gen=js&useskin=codex"></script> <script type="text/javascript">wgBreakFrames=false;wgContentLanguage='en';</script> <script type="text/javascript" src="/web/20121024130027js_/http://codex.wordpress.org/skins/common/wikibits.js"></script> </head> <body id="wordpress-org"> <div id="header"> <div class="wrapper"> <h1><a href="//web.archive.org/web/20121024130027/http://wordpress.org/">WordPress.org</a></h1> <form action="https://web.archive.org/web/20121024130027/http://wordpress.org/search/do-search.php" method="get" id="head-search"> <input class="text" name="search" type="text" value="Search WordPress.org" maxlength="150" onfocus="this.value=(this.value=='Search WordPress.org') ? '' : this.value;" onblur="this.value=(this.value=='') ? 'Search WordPress.org' : this.value;"/> <input type="submit" class="button" value="Go"/> </form> <ul> <li><a href="https://web.archive.org/web/20121024130027/http://wordpress.org/showcase/" title="See some of the sites built on WordPress.">Showcase</a></li> <li><a href="https://web.archive.org/web/20121024130027/http://wordpress.org/extend/themes/" title="Find just the right look for your website.">Themes</a></li> <li><a href="https://web.archive.org/web/20121024130027/http://wordpress.org/extend/plugins/" title="Plugins can extend WordPress to do almost anything you can imagine.">Plugins</a></li> <li><a href="https://web.archive.org/web/20121024130027/http://wordpress.org/extend/mobile/" title="Take your website on the go!">Mobile</a></li> <li><a href="https://web.archive.org/web/20121024130027/http://wordpress.org/support/" title="Forums, documentation, help." class="current">Support</a><ul class="nav-submenu"><li><a href="https://web.archive.org/web/20121024130027/http://wordpress.org/support/" title="Support and discussion forums.">Forums</a></li><li><a href="https://web.archive.org/web/20121024130027/http://codex.wordpress.org/Main_Page" title="Documentation, tutorials, best practices.">Docs</a></li></ul></li> <li><a href="https://web.archive.org/web/20121024130027/http://make.wordpress.org/" title="Contribute your knowledge.">Get Involved</a><ul class="nav-submenu"><li><a href="https://web.archive.org/web/20121024130027/http://make.wordpress.org/core/" title="Write the code.">Core</a></li><li><a href="https://web.archive.org/web/20121024130027/http://make.wordpress.org/ui/" title="Improve the interface.">UI</a></li><li><a href="https://web.archive.org/web/20121024130027/http://make.wordpress.org/accessibility/" title="Create a better experience.">Accessibility</a></li><li><a href="https://web.archive.org/web/20121024130027/http://make.wordpress.org/plugins/" title="Extend the system.">Plugins</a></li><li><a href="https://web.archive.org/web/20121024130027/http://make.wordpress.org/themes/" title="Beautify the web.">Themes</a></li><li><a href="https://web.archive.org/web/20121024130027/http://make.wordpress.org/support/" title="Help the users.">Support</a></li><li><a href="https://web.archive.org/web/20121024130027/http://make.wordpress.org/polyglots/" title="Translate for the world.">Polyglots</a></li><li><a href="https://web.archive.org/web/20121024130027/http://make.wordpress.org/mobile/" title="On the go.">Mobile</a></li></ul></li> <li><a href="https://web.archive.org/web/20121024130027/http://wordpress.org/about/" title="About the WordPress Organization, and where we're going.">About</a></li> <li><a href="https://web.archive.org/web/20121024130027/http://wordpress.org/news/" title="Come here for the latest scoop.">Blog</a></li> <li><a href="https://web.archive.org/web/20121024130027/http://wordpress.org/hosting/" title="Find a home for your blog.">Hosting</a></li> <li id="download"><a href="https://web.archive.org/web/20121024130027/http://wordpress.org/download/" title="Get it. Got it? Good.">Download</a></li> </ul> </div> </div> <div id="headline"> <div class="wrapper"> <h2>Codex</h2> <div class="portlet" id="p-personal"> <p class="login">Codex tools: <a href="/web/20121024130027/http://codex.wordpress.org/index.php?title=Special:UserLogin&returnto=Function_Reference/get_taxonomies">Log in</a> </p> </div> </div> </div> <div id="pagebody"> <div class="wrapper"> <div class="col-10" id="bodyContent"> <h2 class="pagetitle">Function Reference/get taxonomies</h2> <!-- start content --> <table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1"><a href="#Description"><span class="tocnumber">1</span> <span class="toctext">Description</span></a></li> <li class="toclevel-1"><a href="#Usage"><span class="tocnumber">2</span> <span class="toctext">Usage</span></a></li> <li class="toclevel-1"><a href="#Parameters"><span class="tocnumber">3</span> <span class="toctext">Parameters</span></a></li> <li class="toclevel-1"><a href="#Return_Value"><span class="tocnumber">4</span> <span class="toctext">Return Value</span></a></li> <li class="toclevel-1"><a href="#Examples"><span class="tocnumber">5</span> <span class="toctext">Examples</span></a> <ul> <li class="toclevel-2"><a href="#Default_Usage"><span class="tocnumber">5.1</span> <span class="toctext">Default Usage</span></a></li> <li class="toclevel-2"><a href="#Output_a_list_all_registered_taxonomies"><span class="tocnumber">5.2</span> <span class="toctext">Output a list all registered taxonomies</span></a></li> <li class="toclevel-2"><a href="#Output_a_list_of_all_public_custom_taxonomies"><span class="tocnumber">5.3</span> <span class="toctext">Output a list of all public custom taxonomies</span></a></li> <li class="toclevel-2"><a href="#Output_a_named_taxonomy"><span class="tocnumber">5.4</span> <span class="toctext">Output a named taxonomy</span></a></li> </ul> </li> <li class="toclevel-1"><a href="#Source_File"><span class="tocnumber">6</span> <span class="toctext">Source File</span></a></li> <li class="toclevel-1"><a href="#Change_Log"><span class="tocnumber">7</span> <span class="toctext">Change Log</span></a></li> <li class="toclevel-1"><a href="#Related"><span class="tocnumber">8</span> <span class="toctext">Related</span></a></li> </ul> </td></tr></table><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script> <a name="Description" id="Description"></a><h2> <span class="mw-headline"> Description </span></h2> <p>Get a list of registered taxonomy objects. </p> <a name="Usage" id="Usage"></a><h2> <span class="mw-headline"> Usage </span></h2> <p><code><span style="color: #000000"> <span style="color: #0000BB"><?php get_taxonomies</span><span style="color: #007700">( </span><span style="color: #0000BB">$args</span><span style="color: #007700">, </span><span style="color: #0000BB">$output</span><span style="color: #007700">, </span><span style="color: #0000BB">$operator </span><span style="color: #007700">) </span><span style="color: #0000BB">?></span> </span> </code> </p> <a name="Parameters" id="Parameters"></a><h2> <span class="mw-headline"> Parameters </span></h2> <dl><dt> <tt>$args</tt> </dt><dd> (<a href="/web/20121024130027/http://codex.wordpress.org/How_to_Pass_Tag_Parameters#Array" title="How to Pass Tag Parameters"><i>array</i></a>) (<i>optional</i>) An array of key -> value arguments to match against the taxonomies. Only taxonomies having attributes that match all arguments are returned. <dl><dd> Default: <i>None</i> </dd></dl> </dd></dl> <ul><li> name </li><li> object_type (array) </li><li> label </li><li> singular_label </li><li> show_ui </li><li> show_tagcloud </li><li> public </li><li> update_count_callback </li><li> rewrite </li><li> query_var </li><li> manage_cap </li><li> edit_cap </li><li> delete_cap </li><li> assign_cap </li><li> _builtin </li></ul> <dl><dt> <tt>$output</tt> </dt><dd> (<a href="/web/20121024130027/http://codex.wordpress.org/How_to_Pass_Tag_Parameters#String" title="How to Pass Tag Parameters"><i>string</i></a>) (<i>optional</i>) The type of output to return, either taxonomy 'names' or 'objects'. <dl><dd> Default: 'names' </dd></dl> </dd></dl> <dl><dt> <tt>$operator</tt> </dt><dd> (<a href="/web/20121024130027/http://codex.wordpress.org/How_to_Pass_Tag_Parameters#String" title="How to Pass Tag Parameters"><i>string</i></a>) (<i>optional</i>) Operator (and/or) to use with multiple $args. <dl><dd> Default: and </dd></dl> </dd></dl> <a name="Return_Value" id="Return_Value"></a><h2> <span class="mw-headline"> Return Value </span></h2> <dl><dt> array </dt><dd> A list of taxonomy names or objects. If returning names, you will get an array of the taxonomy names such as </dd></dl> <pre> Array ( [special_taxonomy] => special_taxonomy [custom_taxonomy] => custom_taxonomy ) </pre> <p>If returning objects, you will get an array of objects such as: </p> <pre> Array ( [special_taxonomy] => stdClass Object [custom_taxonomy] => stdClass Object ) </pre> <p>wherein each object will contain the following fields: </p> <pre> stdClass Object ( [hierarchical] => [update_count_callback] => [rewrite] => [query_var] => [public] => [show_ui] => [show_tagcloud] => [_builtin] => [labels] => stdClass Object ( [name] => [singular_name] => [search_items] => [popular_items] => [all_items] => [parent_item] => [parent_item_colon] => [edit_item] => [view_item] => [update_item] => [add_new_item] => [new_item_name] => [separate_items_with_commas] => [add_or_remove_items] => [choose_from_most_used] => [menu_name] => [name_admin_bar] => ) [show_in_nav_menus] => [cap] => stdClass Object ( [manage_terms] => [edit_terms] => [delete_terms] => [assign_terms] => ) [name] => [object_type] => Array () [label] ) </pre> <a name="Examples" id="Examples"></a><h2> <span class="mw-headline"> Examples </span></h2> <a name="Default_Usage" id="Default_Usage"></a><h3> <span class="mw-headline"> Default Usage </span></h3> <p>The call to <strong class="selflink">get_taxonomies</strong> returns the registered taxonomies. </p> <pre><?php $taxonomies=get_taxonomies(); ?> </pre> <a name="Output_a_list_all_registered_taxonomies" id="Output_a_list_all_registered_taxonomies"></a><h3> <span class="mw-headline">Output a list all registered taxonomies</span></h3> <pre> <?php $taxonomies=get_taxonomies('','names'); foreach ($taxonomies as $taxonomy ) { echo '<p>'. $taxonomy. '</p>'; } ?> </pre> <a name="Output_a_list_of_all_public_custom_taxonomies" id="Output_a_list_of_all_public_custom_taxonomies"></a><h3> <span class="mw-headline">Output a list of all public custom taxonomies</span></h3> <p>This return all custom (not builtin) taxonomies. </p> <pre> <?php $args=array( 'public' => true, '_builtin' => false ); $output = 'names'; // or objects $operator = 'and'; // 'and' or 'or' $taxonomies=get_taxonomies($args,$output,$operator); if ($taxonomies) { foreach ($taxonomies as $taxonomy ) { echo '<p>'. $taxonomy. '</p>'; } } ?> </pre> <a name="Output_a_named_taxonomy" id="Output_a_named_taxonomy"></a><h3> <span class="mw-headline">Output a named taxonomy</span></h3> <p>This example uses the 'object' output to retrieve and display the taxonomy called 'genre': </p> <pre> <?php $args=array( 'name' => 'genre' ); $output = 'objects'; // or objects $taxonomies=get_taxonomies($args,$output); if ($taxonomies) { foreach ($taxonomies as $taxonomy ) { echo '<p>' . $taxonomy->name . '</p>'; } } ?> </pre> <a name="Source_File" id="Source_File"></a><h2> <span class="mw-headline"> Source File </span></h2> <p><tt>get_taxonomies()</tt> is located in <code><a href="https://web.archive.org/web/20121024130027/http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/taxonomy.php#L0" class="external text" title="http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/taxonomy.php#L0">wp-includes/taxonomy.php</a></code>. </p> <a name="Change_Log" id="Change_Log"></a><h2> <span class="mw-headline"> Change Log </span></h2> <ul><li> Since: 3.0.0 </li></ul> <a name="Related" id="Related"></a><h2> <span class="mw-headline"> Related </span></h2> <div style="clear:both; background-color:#F7F7F7; border:1px solid #CCCCCC; color:#000000; padding:7px; margin:0.5em auto 0.5em auto; vertical-align:middle;">See also index of <a href="/web/20121024130027/http://codex.wordpress.org/Function_Reference" title="Function Reference">Function Reference</a> and index of <a href="/web/20121024130027/http://codex.wordpress.org/Template_Tags" title="Template Tags">Template Tags</a>.</div> <!-- NewPP limit report Preprocessor node count: 108/1000000 Post-expand include size: 1245/2097152 bytes Template argument size: 515/2097152 bytes Expensive parser function count: 0/100 --> <div class="printfooter"> Retrieved from "<a href="https://web.archive.org/web/20121024130027/http://codex.wordpress.org/Function_Reference/get_taxonomies">http://codex.wordpress.org/Function_Reference/get_taxonomies</a>"</div> <div id="catlinks"><div id="catlinks" class="catlinks"><div id="mw-normal-catlinks"><a href="/web/20121024130027/http://codex.wordpress.org/Special:Categories" title="Special:Categories">Category</a>: <span dir="ltr"><a href="/web/20121024130027/http://codex.wordpress.org/Category:Template_Tags" title="Category:Template Tags">Template Tags</a></span></div></div></div> <!-- end content --> </div> <div class="col-2"> <ul class="submenu"> <li id="n-mainpage"><a href="/web/20121024130027/http://codex.wordpress.org/Main_Page">Home Page</a></li> <li><a href="/web/20121024130027/http://codex.wordpress.org/WordPress_Lessons">WordPress Lessons</a></li> <li><a href="/web/20121024130027/http://codex.wordpress.org/Getting_Started_with_WordPress">Getting Started</a></li> <li><a href="/web/20121024130027/http://codex.wordpress.org/Working_with_WordPress">Working with WordPress</a></li> <li><a href="/web/20121024130027/http://codex.wordpress.org/Blog_Design_and_Layout">Design and Layout</a></li> <li><a href="/web/20121024130027/http://codex.wordpress.org/Advanced_Topics">Advanced Topics</a></li> <li><a href="/web/20121024130027/http://codex.wordpress.org/Troubleshooting">Troubleshooting</a></li> <li><a href="/web/20121024130027/http://codex.wordpress.org/Developer_Documentation">Developer Docs</a></li> <li><a href="/web/20121024130027/http://codex.wordpress.org/About_WordPress">About WordPress</a></li> </ul> <h3>Codex Resources</h3> <ul class="submenu"> <li id="n-portal"><a href="/web/20121024130027/http://codex.wordpress.org/Codex:Community_Portal">Community portal</a></li> <li id="n-currentevents"><a href="/web/20121024130027/http://codex.wordpress.org/Current_events">Current events</a></li> <li id="n-recentchanges"><a href="/web/20121024130027/http://codex.wordpress.org/Special:RecentChanges">Recent changes</a></li> <li id="n-randompage"><a href="/web/20121024130027/http://codex.wordpress.org/Special:Random">Random page</a></li> <li id="n-help"><a href="/web/20121024130027/http://codex.wordpress.org/Help:Contents">Help</a></li> </ul> </div> </div> </div> <div id="footer"> <div class="wrapper"> <p> <a href="https://web.archive.org/web/20121024130027/http://wordpress.org/about/privacy/">Privacy</a> | <a href="https://web.archive.org/web/20121024130027/http://wordpress.org/about/license/">License / GPLv2</a> See also: <a href="https://web.archive.org/web/20121024130027/http://wordpress.com/?ref=wporg-footer" title="Hassle-free WP hosting">WordPress.com</a> | <a href="https://web.archive.org/web/20121024130027/http://wordpress.tv/" title="Videos, tutorials, WordCamps">WordPress.TV</a> | <a href="https://web.archive.org/web/20121024130027/http://central.wordcamp.org/" title="Find a WordPress event near your home">WordCamp</a> | <a href="https://web.archive.org/web/20121024130027/http://jobs.wordpress.net/" title="Find or post WordPress jobs">WP Jobs</a> | <a href="https://web.archive.org/web/20121024130027/http://ma.tt/" title="Co-founder of WordPress, an example of what WordPress can do">Matt</a> | <a href="https://web.archive.org/web/20121024130027/http://wordpress.org/news/feed/" class="rsslink">Blog RSS</a> </p> <br/> <iframe src="https://web.archive.org/web/20121024130027if_/http://www.facebook.com/plugins/like.php?app_id=121415197926116&href=http%3A%2F%2Fwww.facebook.com%2Fwordpress&send=false&layout=button_count&width=150&show_faces=false&action=like&colorscheme=light&font=lucida+grande&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:150px; height:21px;" allowtransparency="true"></iframe> <!-- <div class="g-plusone" data-size="medium" data-href="https://plus.google.com/107188080561309681193"></div> --> <iframe allowtransparency="true" frameborder="0" scrolling="no" src="https://web.archive.org/web/20121024130027if_/http://platform.twitter.com/widgets/follow_button.html?screen_name=WordPress&show_count=false" style="width:150px; height:20px;"></iframe> <h6>Code is Poetry</h6> </div> </div> <script type="text/javascript">_qoptions={qacct:"p-18-mFEk4J448M"};</script> <script type="text/javascript" src="https://web.archive.org/web/20121024130027js_/http://edge.quantserve.com/quant.js"></script> <noscript><img src="https://web.archive.org/web/20121024130027im_/http://pixel.quantserve.com/pixel/p-18-mFEk4J448M.gif" style="display: none;" border="0" height="1" width="1" alt=""/></noscript> <!-- --> <script type="text/javascript" src="https://web.archive.org/web/20121024130027js_/http://s.gravatar.com/js/gprofiles.js"></script> <script type="text/javascript"> (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://web.archive.org/web/20121024130027/https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); </script> <script type="text/javascript"> (function($){ $(document).ready(function() { $('#footer a').click(function() { if (this.href.indexOf('wordpress.org') == -1 && this.href.indexOf('http') == 0) { recordOutboundLink(this, 'Outbound Links', this.href); return false; } }); }); })(jQuery); </script> </body> <!-- Cached 20121004165003 --> </html> </body> <!-- Cached 20121004165003 --> </html> <!-- FILE ARCHIVED ON 13:00:27 Oct 24, 2012 AND RETRIEVED FROM THE INTERNET ARCHIVE ON 00:10:31 Nov 29, 2024. JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. SECTION 108(a)(3)). --> <!-- playback timings (ms): captures_list: 0.538 exclusion.robots: 0.027 exclusion.robots.policy: 0.016 esindex: 0.011 cdx.remote: 7.228 LoadShardBlock: 198.795 (3) PetaboxLoader3.datanode: 103.553 (4) PetaboxLoader3.resolve: 168.801 (3) load_resource: 195.156 -->