Advertisement
olie480

WP - Taxonomy/Category List, with associated Posts

Dec 18th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.99 KB | None | 0 0
  1. <?php
  2. get_header();
  3. $term = get_term_by('slug', get_query_var('term' ), get_query_var('taxonomy'));
  4. ?>
  5. <div id="info-cnt">
  6.   <div id="info-lg" class="info-style <?= $p; ?>">
  7.     <!-- Download PDF -->
  8.     <div id="bx-pdf"> <img src="<?php bloginfo('template_url'); ?>/images/icon-pdf.gif" alt="PDF Document" width="20" height="20">
  9.       <p><a href="<?php bloginfo('home'); ?>/pdf/menu-<?= $term->slug;?>.pdf" title="Download PDF" target="_blank">Download PDF</a></p>
  10.     </div>
  11.     <h1><?= $term->name; ?></h1>
  12. <?php
  13.  
  14. // get all the categories from the database
  15. $args = array(
  16.                  'type'     => 'menu-items',
  17.                  'parent'   => $term->term_id,
  18.                  'taxonomy' => 'menu-cat',
  19.             );  
  20. $cats = get_categories($args);
  21. ?>
  22. <div class="menu">
  23.         <?php   if(is_tax('menu-cat') && isset($is_mobile)): ?>
  24.                         <a href="<?php bloginfo('url'); ?>/menus/" id="mobile-menu" class="btn">MENUS</a>
  25.     <?php else: ?>
  26.                         <a href="<?php bloginfo('url'); ?>/menus/" class="btn desktop-menu">BACK TO MENUS</a>    
  27.         <?php endif; ?>
  28. <p>Kitchen Open Until 1AM Daily</p>
  29. <hr>    
  30. <?php
  31.  
  32. // loop through the categries
  33. foreach ($cats as $cat) :
  34.     // setup the cateogory ID
  35.     $cat_id = $cat->term_id;
  36.     // Make a header for the cateogry
  37.     echo "<h2>".$cat->name."</h2>";
  38.  
  39.         $termDescription = term_description( $cat->term_id, get_query_var( 'taxonomy' ) );
  40.    
  41.         echo ($termDescription ? "<div class='tag-desc'>$termDescription</div>" : "");
  42.  
  43.     // create a custom wordpress query
  44.     //query_posts("cat=$cat_id&post_per_page=100");
  45.     $arg = array(
  46.         'post_type' => 'menu-items',
  47.         'tax_query' => array(
  48.             array(
  49.                 'taxonomy' => 'menu-cat',
  50.                 'field' => 'id',
  51.                 'terms' => array($cat_id)
  52.             )
  53.          ),
  54.          'orderby' => 'menu_order',
  55.          'order' => 'asc'
  56.        
  57.     );
  58.     $items = new WP_Query($arg);
  59.     // start the wordpress loop
  60.     while ($items->have_posts()) : $items->the_post(); ?>
  61.             <?php idea_menu(); ?>  
  62.       <?php
  63.     endwhile;
  64. endforeach; ?>
  65.     </div>    
  66.   </div>
  67. </div>
  68. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement