Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@RevConcept
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RevConcept/d2cb5148a37244df0469 to your computer and use it in GitHub Desktop.
Save RevConcept/d2cb5148a37244df0469 to your computer and use it in GitHub Desktop.
<?php
function recipe_product_filter() {
global $post;
// Query products
$query = new WP_Query(array(
'post_type' => 'recipes',
'meta_key' => 'recipe_products_2',
'post_status' => 'publish',
));
if($query->have_posts()): ?>
<h3>Filter by product:</h3>
<form action="" method="post">
<select name="product_selection" id="product_selection" class="postform" onchange="submit();">
<option selected="selected">Choose product</option>
<?php while( $query->have_posts() ): $query->the_post();
$products = get_field('recipe_products_2');
if($products) {
foreach($products as $product) {
echo '<option class="level-0" value="' . $product->ID . '">';
echo $product->post_title;
echo '</option>';
}
}
?>
<?php endwhile; ?>
</select>
</form>
<?php endif; wp_reset_postdata();
}
// VAR DUMP OF $products
array(3) {
[0]=>
object(WP_Post)#451 (24) {
["ID"]=>
int(207)
["post_author"]=>
string(1) "2"
["post_date"]=>
string(19) "2013-05-03 17:28:58"
["post_date_gmt"]=>
string(19) "2013-05-03 17:28:58"
["post_content"]=>
string(286) "I've eaten my way all around the world but whether growing up in my own neighborhood or traveling abroad, Latin flavors have always been a constant in my life. Meet Hak's BBQs new fiery addition: a robust balance of sweet, zesty and explosive heat!
Habanero Pineapple. You need this."
["post_title"]=>
string(24) "Hak's Habanero Pineapple"
["post_excerpt"]=>
string(0) ""
["post_status"]=>
string(7) "publish"
["comment_status"]=>
string(4) "open"
["ping_status"]=>
string(6) "closed"
["post_password"]=>
string(0) ""
["post_name"]=>
string(23) "haks-habanero-pineapple"
["to_ping"]=>
string(0) ""
["pinged"]=>
string(0) ""
["post_modified"]=>
string(19) "2014-12-03 20:59:31"
["post_modified_gmt"]=>
string(19) "2014-12-03 20:59:31"
["post_content_filtered"]=>
string(0) ""
["post_parent"]=>
int(0)
["guid"]=>
string(54) "http://chris-mac.local:5757/?post_type=product&p=207"
["menu_order"]=>
int(2)
["post_type"]=>
string(7) "product"
["post_mime_type"]=>
string(0) ""
["comment_count"]=>
string(1) "0"
["filter"]=>
string(3) "raw"
}
[1]=>
object(WP_Post)#450 (24) {
["ID"]=>
int(214)
["post_author"]=>
string(1) "2"
["post_date"]=>
string(19) "2013-05-03 17:46:17"
["post_date_gmt"]=>
string(19) "2013-05-03 17:46:17"
["post_content"]=>
string(185) "The ultimate way to enhance your grill. Available exclusively when purchased together with Hak's gourmet BBQ sauces. 2 pounds of meticulously cured hickory smoking chips. You need this!"
["post_title"]=>
string(42) "Hak's Hickory Bourbon Soaked Smoking Chips"
["post_excerpt"]=>
string(0) ""
["post_status"]=>
string(7) "publish"
["comment_status"]=>
string(4) "open"
["ping_status"]=>
string(6) "closed"
["post_password"]=>
string(0) ""
["post_name"]=>
string(41) "haks-hickory-bourbon-soaked-smoking-chips"
["to_ping"]=>
string(0) ""
["pinged"]=>
string(0) ""
["post_modified"]=>
string(19) "2014-12-03 22:18:20"
["post_modified_gmt"]=>
string(19) "2014-12-03 22:18:20"
["post_content_filtered"]=>
string(0) ""
["post_parent"]=>
int(0)
["guid"]=>
string(54) "http://chris-mac.local:5757/?post_type=product&p=214"
["menu_order"]=>
int(4)
["post_type"]=>
string(7) "product"
["post_mime_type"]=>
string(0) ""
["comment_count"]=>
string(1) "0"
["filter"]=>
string(3) "raw"
}
[2]=>
object(WP_Post)#452 (24) {
["ID"]=>
int(204)
["post_author"]=>
string(1) "2"
["post_date"]=>
string(19) "2013-05-03 17:22:19"
["post_date_gmt"]=>
string(19) "2013-05-03 17:22:19"
["post_content"]=>
string(344) "My chef career took me on a culinary journey through southeast Asia where I created recipes fusing local ingredients with my Mediterranean roots. The result? Hak's BBQs east meets west addition, which combines the deep sweetness of dates, tangy tamarind, bright lemongrass and the richness of sesame oil.
Thai Chile Tamarind.
You need this."
["post_title"]=>
string(25) "Hak's Thai Chile Tamarind"
["post_excerpt"]=>
string(0) ""
["post_status"]=>
string(7) "publish"
["comment_status"]=>
string(4) "open"
["ping_status"]=>
string(6) "closed"
["post_password"]=>
string(0) ""
["post_name"]=>
string(24) "haks-thai-chile-tamarind"
["to_ping"]=>
string(0) ""
["pinged"]=>
string(0) ""
["post_modified"]=>
string(19) "2014-12-03 20:59:32"
["post_modified_gmt"]=>
string(19) "2014-12-03 20:59:32"
["post_content_filtered"]=>
string(0) ""
["post_parent"]=>
int(0)
["guid"]=>
string(54) "http://chris-mac.local:5757/?post_type=product&p=204"
["menu_order"]=>
int(1)
["post_type"]=>
string(7) "product"
["post_mime_type"]=>
string(0) ""
["comment_count"]=>
string(1) "0"
["filter"]=>
string(3) "raw"
}
}
array(3) {
[0]=>
object(WP_Post)#553 (24) {
["ID"]=>
int(207)
["post_author"]=>
string(1) "2"
["post_date"]=>
string(19) "2013-05-03 17:28:58"
["post_date_gmt"]=>
string(19) "2013-05-03 17:28:58"
["post_content"]=>
string(286) "I've eaten my way all around the world but whether growing up in my own neighborhood or traveling abroad, Latin flavors have always been a constant in my life. Meet Hak's BBQs new fiery addition: a robust balance of sweet, zesty and explosive heat!
Habanero Pineapple. You need this."
["post_title"]=>
string(24) "Hak's Habanero Pineapple"
["post_excerpt"]=>
string(0) ""
["post_status"]=>
string(7) "publish"
["comment_status"]=>
string(4) "open"
["ping_status"]=>
string(6) "closed"
["post_password"]=>
string(0) ""
["post_name"]=>
string(23) "haks-habanero-pineapple"
["to_ping"]=>
string(0) ""
["pinged"]=>
string(0) ""
["post_modified"]=>
string(19) "2014-12-03 20:59:31"
["post_modified_gmt"]=>
string(19) "2014-12-03 20:59:31"
["post_content_filtered"]=>
string(0) ""
["post_parent"]=>
int(0)
["guid"]=>
string(54) "http://chris-mac.local:5757/?post_type=product&p=207"
["menu_order"]=>
int(2)
["post_type"]=>
string(7) "product"
["post_mime_type"]=>
string(0) ""
["comment_count"]=>
string(1) "0"
["filter"]=>
string(3) "raw"
}
[1]=>
object(WP_Post)#554 (24) {
["ID"]=>
int(217)
["post_author"]=>
string(1) "2"
["post_date"]=>
string(19) "2013-05-03 18:14:18"
["post_date_gmt"]=>
string(19) "2013-05-03 18:14:18"
["post_content"]=>
string(72) "Pick any 3 bottles of Hak's to create your ultimate pack. You need this."
["post_title"]=>
string(26) "Hak's Mix and Match 3 Pack"
["post_excerpt"]=>
string(0) ""
["post_status"]=>
string(7) "publish"
["comment_status"]=>
string(4) "open"
["ping_status"]=>
string(6) "closed"
["post_password"]=>
string(0) ""
["post_name"]=>
string(25) "haks-mix-and-match-3-pack"
["to_ping"]=>
string(0) ""
["pinged"]=>
string(0) ""
["post_modified"]=>
string(19) "2014-12-03 20:59:31"
["post_modified_gmt"]=>
string(19) "2014-12-03 20:59:31"
["post_content_filtered"]=>
string(0) ""
["post_parent"]=>
int(0)
["guid"]=>
string(54) "http://chris-mac.local:5757/?post_type=product&p=217"
["menu_order"]=>
int(3)
["post_type"]=>
string(7) "product"
["post_mime_type"]=>
string(0) ""
["comment_count"]=>
string(1) "0"
["filter"]=>
string(3) "raw"
}
[2]=>
object(WP_Post)#555 (24) {
["ID"]=>
int(364)
["post_author"]=>
string(1) "2"
["post_date"]=>
string(19) "2014-06-25 15:00:19"
["post_date_gmt"]=>
string(19) "2014-06-25 15:00:19"
["post_content"]=>
string(284) "I take a global approach to BBQ flavors and I made no exception with this South Carolina inspired new addition. Maple syrup is smoked for depth and sweetness and the perfect blend of whole grain mustards deliver texture along with a tangy finish. Put in on everything! I certainly do."
["post_title"]=>
string(26) "Hak's Smoked Maple Mustard"
["post_excerpt"]=>
string(0) ""
["post_status"]=>
string(7) "publish"
["comment_status"]=>
string(4) "open"
["ping_status"]=>
string(6) "closed"
["post_password"]=>
string(0) ""
["post_name"]=>
string(25) "haks-smoked-maple-mustard"
["to_ping"]=>
string(0) ""
["pinged"]=>
string(0) ""
["post_modified"]=>
string(19) "2014-12-18 01:11:53"
["post_modified_gmt"]=>
string(19) "2014-12-18 01:11:53"
["post_content_filtered"]=>
string(0) ""
["post_parent"]=>
int(0)
["guid"]=>
string(54) "http://chris-mac.local:5757/?post_type=product&p=364"
["menu_order"]=>
int(0)
["post_type"]=>
string(7) "product"
["post_mime_type"]=>
string(0) ""
["comment_count"]=>
string(1) "0"
["filter"]=>
string(3) "raw"
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment