Question

I want to show several comics I make without having to rely on plugins (already tried them, each has some limitations I rather just do the work on my own). So I made a parent category called Comics and a child category for each comic series, Title1 and Title2 for example. Right now, going into domain/comics shows the archive as it is defined by the theme, with all the pages of Title1 and Title2 available. But going to domain/comics/title1 redirects to a single page view.

I would like to show the archive of each series in a different way the archive for blog posts, gallery images and the rest of the content of the page is shown, and creating a category-comics.php file only alters the behavior of the Comics archive and not of Series1 and Series2. How would you go about it?

EDIT: I originally phrased it not to mention I am trying to do comics to make it more applicable to other situations but was told I should say exactly what am I trying to do so I rewrote it to my specifics.

EDIT2: If anyone is wondering, Im basing my wordpress theme of the Neve theme right now. https://themeisle.com/themes/neve/

EDIT3: I have looked around and I think the piece I'm missing is how figure out the query that was made. So if the site loads archive.php, I can put a conditional clause "If category is child of Comic, load comic archive template"

Was it helpful?

Solution

I just found it out!

By using get_query_var ( 'cat' ) you get the value of the category in the query. So you can use cat_is_ancestor_of ( parent-cat-id, get_query_var ( 'cat' ) ) which will return true if you are looking at a child of a specific parent category. And from there you can modify your archive page to load whatever templates they need.

And regarding the issue of going to single page view, it had something to do with permalink. Setting them to "plain" made it work correctly

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top