Use category slugs in includes parameter for get_categories?
-
I’d like to use category slugs instead of category IDs in the “includes” parameter for get_categories. Here’s the code I am using:
<?php $args = array( 'orderby' => 'name', 'parent' => 0, 'hide_empty' => 0, 'include' => '' ); $categories = get_categories( $args ); foreach ( $categories as $category ) { echo '<option value="' . $category->cat_ID . '" name="cat">IN ' . $category->name . '</option>'; } ?>
But I want to be able to use slugs instead of IDs when I list the categories to include. I am using a wordpress multisite, and I want the same categories to be listed in this dropdown list from site to site — but the categories have the same slugs but different IDs from site to site.
Any help would be greatly appreciated! Thank you!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Use category slugs in includes parameter for get_categories?’ is closed to new replies.