Image may be NSFW.
Clik here to view. I want to let my random quote generator users choose which quote category they want to see a quote from when they automatically post the quote to their Facebook page. I want to show my quote categories, which are a custom taxonomy (quote_categories), on my custom post type (quote).
Here is the code I use:
// $args = array( 'orderby' => 'name', 'show_count' => 0, 'pad_counts' => 0, 'hierarchical' => 1, 'show_option_all' => 'Any', 'taxonomy' => 'quote_categories', ); echo '<form action="" method="post" >'; wp_dropdown_categories($args); echo '<input type="submit" value="Get Quote" />'; echo '</form>'; //
It gives me the quote_categories id in the $_POST['cat']
variable. If they choose ‘ANY’, the id is 0. I can then use this code to get my quote category name:
// $cat = get_term($_POST['cat'],'quote_categories'); //
The post Display My Custom Post Categories (Custom Taxonomy) in a Dropdown appeared first on Cullen Web Services.