Advertisement
rakeshr

custom post type with custom taxonomy

Nov 8th, 2011
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.39 KB | None | 0 0
  1. <?php
  2. /*
  3. Template Name: Applications
  4. */
  5.  
  6.  
  7.  
  8. get_header(); ?>
  9.  
  10. <div id="ppagewrapper" >       
  11.  
  12.  
  13.  
  14.  
  15. <?php
  16. //list terms in a given taxonomy
  17. $taxonomy = 'apptypes';
  18. $appargs=array(
  19.   'hide_empty' => false,
  20.   'orderby' => 'name',
  21.   'order' => 'ASC',
  22.   'parent' => '0'
  23. );
  24. $appterms = get_terms($taxonomy,$appargs);
  25. ?>
  26.  
  27. <?php
  28. foreach ($appterms as $appterm) {
  29.  
  30. $termID = $appterm->term_id;
  31. $taxonomyName = $taxonomy;
  32. $termchildren = get_term_children( $termID, $taxonomyName );
  33. foreach ($termchildren as $child) {
  34.     $termsub = get_term_by( 'id', $child, $taxonomyName );
  35.     echo '<div style="margin:0 auto; width="100%"><h2>'. $appterm->name.'</h2></div>';
  36.     echo $termsub->name;
  37.  
  38.  
  39.   $wpq = array ('taxonomy'=>$taxonomy,'term'=>$termsub->slug);
  40. $query = new WP_Query ($wpq);
  41. $article_count = $query->post_count;
  42. echo '<table width="98%" border="0" cellspacing="0" cellpadding="5"  class="customtable">
  43.  <tr class="customhead">
  44.    <td align="left" valign="top">Year</td>
  45.    <td align="left" valign="top">Kit Name</td>
  46.    <td align="left" valign="top">Kit</td>
  47.  </tr>
  48.   <tr><td colspan="3">'.term_description($termsub->term_id,$taxonomyName) .'</td></tr>';   
  49.  
  50. if ($article_count) {
  51. $posts = $query->posts;
  52. foreach ($posts as $post) {
  53. include(MY_THEME_FOLDER . '/appsloop.php');
  54. }
  55. }
  56. echo ' </table>';
  57.  
  58.  
  59.  
  60. } }
  61. ?>
  62. </ul>
  63.  
  64.  
  65.    
  66.   </div>
  67.    
  68.  
  69.  
  70.  
  71. <?php get_footer(); ?>
  72.  
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement