title: Getting a category name by ID from a custom post type
body: <p>I'm trying to figure out how to fetch a category name/title via it's ID when it's part of a custom post type. </p>
  
  <p>In this instance, I'm using Comic Easel, and for the custom post type of "comic" you have "chapters" and basically each chapter you add has an ID. In my case, chapter-1 (which is the slug) has an ID of 7.</p>
  
  <p>I found out you can't call on a category by ID for a custom post type in the regular way you do it for categories created for WP posts or pages (which makes sense). </p>
  
  <p>It's for a comic archive page, where the functionality is thumbnails of the comic pages are generated as they are posted and organized by the chapters they're categorized under. </p>
  
  <p>Here's the code I'm using to generate thumbnails, page titles, and post dates for those pages in a specific chapter:</p>
  
  <pre><code>&lt;div class="pagerow" id="Chapter 1"&gt;
  &lt;?php 
    $comicpage_loop = new WP_Query( array( 'chapters' =&gt; 'chapter-1', 'post_type' =&gt; 'comic', 'posts_per_page' =&gt; '999', get_post_meta($post-&gt;ID, 'ep_comic_posts_per_page', true), 'order' =&gt; 'ASC')); 
  ?&gt;
  
  &lt;h2 class="chaptitle"&gt;&lt;/h2&gt;
   &lt;?php 
    while ($comicpage_loop-&gt;have_posts()) : $comicpage_loop-&gt;the_post();
   ?&gt;
  
  &lt;div class="pages"&gt;
   &lt;div class="pagetitle"&gt;&lt;?php the_title(); ?&gt;&lt;/div&gt;
      &lt;div class="pagethumb"&gt;
      &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;
       &lt;?php 
         the_post_thumbnail('custom-2'); 
       ?&gt;
      &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="pubdate"&gt;&lt;?php the_time('F j, Y') ?&gt;&lt;/div&gt;
   &lt;/div&gt;
  
    &lt;?php endwhile; ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>See the h2 tag "chaptitle"? That's where I'd like the chapter ie "Chapter 1" to display. </p>
  
  <p>Is there a way I can pull up and display the chapter name in the query I already have going? </p>
  
  <p>EDIT</p>
  
  <p>Ok going by Boris's suggestion, I also found an example for get_term_child (I'm not using the child part but the rest of the syntax seemed helpful. Here's what I've ended up with and it does display the chapter title:</p>
  
  <pre><code>&lt;?php
  $term_id = 7;
  $taxonomy_name = 'chapters';
  $chapname = get_term($term_id, $taxonomy);
  ?&gt;
  
  &lt;h2 class="chaptitle"&gt;&lt;?php echo $chapname-&gt;name; ?&gt;&lt;/h2&gt;
  </code></pre>
  
  <p>Is this right?</p>
  
  <p>EDIT 2</p>
  
  <p>I'm also finding adding this to my main query works as an alternative method:</p>
  
  <pre><code>$chapname = get_term($term_id = 7, $taxonomy_name ='chapters'),
  </code></pre>
  
  <p>I wonder though, is there a way to get the category ID in this query so I wouldn't have to put "7" for $term_id?
  To me not having to hardcode an id in would be ideal. </p>