Screen Shot 2013-10-17 at 6.18.53 PM 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" >';
    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');

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top