Storyline Traversal Template Tags

ComicPress Core provides functions for traversing the storyline categories themselves. These are used to find the adjacent (previous, next, parent) categories of a particular category, and to find how deep in the hierarchy a category is located.

SL() and SC()

SL() and SC() give you access to the current storyline category information. SL() lists all of the categories, in order, with the necessary metadata to traverse and understand the structure. SC() lets you quickly traverse the storyline, returning category objects as it goes.

foreach (SL() as $category_id => $info) {
  $category = get_category($category_id);
  printf('Category %d is %d levels deep', $category->name, $info['level']);
}

// by default, SC() returns categories relative to the current post
$next = SC('next');
$previous = SC('previous');
$parent = SC('parent');

// or you can provide a category to be relative to
$next_from_three = SC('next', 3);
$previous_to_chapter_four = SC('previous', 'chapter-four');