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.
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.
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).
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.
Here's the code I'm using to generate thumbnails, page titles, and post dates for those pages in a specific chapter:
<div class="pagerow" id="Chapter 1">
<?php
$comicpage_loop = new WP_Query( array( 'chapters' => 'chapter-1', 'post_type' => 'comic', 'posts_per_page' => '999', get_post_meta($post->ID, 'ep_comic_posts_per_page', true), 'order' => 'ASC'));
?>
<h2 class="chaptitle"></h2>
<?php
while ($comicpage_loop->have_posts()) : $comicpage_loop->the_post();
?>
<div class="pages">
<div class="pagetitle"><?php the_title(); ?></div>
<div class="pagethumb">
<a href="<?php the_permalink(); ?>">
<?php
the_post_thumbnail('custom-2');
?>
</a>
</div>
<div class="pubdate"><?php the_time('F j, Y') ?></div>
</div>
<?php endwhile; ?>
</div>
See the h2 tag "chaptitle"? That's where I'd like the chapter ie "Chapter 1" to display.
Is there a way I can pull up and display the chapter name in the query I already have going?
EDIT
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:
<?php
$term_id = 7;
$taxonomy_name = 'chapters';
$chapname = get_term($term_id, $taxonomy);
?>
<h2 class="chaptitle"><?php echo $chapname->name; ?></h2>
Is this right?
EDIT 2
I'm also finding adding this to my main query works as an alternative method:
$chapname = get_term($term_id = 7, $taxonomy_name ='chapters'),
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.