codebloo

PODS Faq - grouping questions by WooCommerce product types

Dec 13th, 2012
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. <?php
  2. //initialize pods
  3. $category = SOMEHOW REFERENCE WOOCOMMERCE PRODUCT CATEGORY TAXONOMY
  4. $questions = new Pod('ask_washroom_guy');
  5.  
  6. //Get categories sorted by name
  7. $category->findRecords('t.name',-1);
  8.  
  9. while($category->fetchRecord()){
  10. $catName = $category->get_field('name');
  11. $catID = $category->get_field('id');
  12. ?>
  13.  
  14. //output the category name as a header
  15. <h3 id="<?php echo $catID; ?>" class="cat"><?php echo $catName; ?></h3>
  16.  
  17. <?php
  18. //Query for all FAQ questions belonging to this category slug
  19. //findRecords([sort by display_order], [return all results],
  20. //[where category matches])
  21. $questions->findRecords('display_order DESC', -1, 'category.slug LIKE "'. $catSlug .'"');
  22.  
  23. while($questions->fetchRecord()){
  24. $question_name = $questions->get_field('name');
  25. $question_question = $questions->get_field('question');
  26. $question_answer = $questions->get_field('answer');
  27. $question_display_order = $questions->get_field('display_order');
  28. $question_slug = $questions->get_field('slug');
  29. ?>
  30. // Output the questions in this format
  31. <div class="question">
  32. <h4><?php echo $question_question; ?></h4>
  33. <p><?php echo $question_answer; ?></p>
  34. </div>
  35.  
  36. <?php
  37. }
  38. ?>
  39.  
  40. <?php
  41. }
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment