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
Related Posts:
- Display only posts from referred category on date archive page
- WordPress subcategories return 404 in custom template
- Restoring default article pagination on archives – Removing custom limits
- How to get category and archive title?
- Get rid of WordPress category, tag and author archives?
- How To Create A Paginated List Of All Categories On My Site?
- get_categories for custom post type with a specific custom taxonomy attached
- How To Modify The Loop in archives.php To Have 11 Posts Per Page and CSS Styling
- 404 Error On Category and Tags Pages
- Decreasing the Memory Consumption of a WordPress Site?
- What’s the URL for a category archive?
- Sort posts by tags in category pages
- Display posts links from a category group by year
- Display list of Sub-Categories and the posts they contain, within one main Category
- Sort category page with custom field
- How to create tabled index of posts in a certain category
- How would you create a “weekly” archive?
- Sticky Posts Not Sticking to Top of Category Archive
- Root level category, tag, author and archive pages to work
- Category Specific Archive
- How to have Multiple Archives Widgets, one archive widget per category (in a different page)?
- Are Custom Taxonomy Templates Possible?
- “Sticky” posts for each category (archive.php)
- I want exclude the particular category in sidebar
- Which php file lists all the post of a category
- Remove Archive Headline and Archive Intro Text fields on category and tag archive pages in WordPress Admin with Genesis framework
- Using widget logic I want to show only a widget on the archive page if there are no posts
- What type of page should i use? static page or category page? and what’s the difference? [closed]
- Creating archive pages for children categories
- WordPress categories being called “archives” in google links. How to remove?
- conditional for sub category on archive page
- Sorting posts by season
- weekly archive for custom category
- How to remove category titles?
- Show archives by year from just one category
- Category index featured image
- Archive.php filtered by pre-determined category
- How do I call posts with a certain tag?
- Category being displayed without base parmalink
- How to change category and year archive permalinks/rewrite rules?
- Get parrent category name
- add_rewrite_endpoint returns 404 on archives
- Multiple category archive page
- Custom archive.php: retrieve right post categories?
- wp_dropdown_categories() scripts working erratically on sidebar
- Yearly Archive for Categories with dropdown
- Category archives with monthly pagination
- Customize category page for different custom taxonomies
- Category archive is displaying all posts rather than the specific category
- How to Remove a Title from All Category and Tags Page?
- Do not show sub categories in the loop on archive-product.php
- Is it possible to have a template that works on multiple categories where the link address contains the specific category?
- How to get posts by category at /%category%/ url?
- About title on a page
- why get_the_post_thumbnail( the_ID()) echos extra post id
- Image loading function not working on archive.php template
- display category list year wise in wordpress
- How to display post in custom file not in archive file?
- Media (images, videos, etc.) not showing on Category page
- WordPress monthly archive category specific
- Problem with multiple loops in wordpress theme
- Displaying year once in category.php [duplicate]
- Archive filtering
- Show Secondary Sidebar on Category pages (archive)
- Rebuilding a Site: How to Show Several Category Posts in Woo Framework Theme?
- Add multiple orderby with pre get posts
- show only sub categories if available?
- How to overwrite the category template in a plugin
- Different post slug based on archive
- List of post categories only associated to another custom taxonomy
- How to prevent WordPress from redirecting single page to prefixed category archive with same name?
- Show the parent taxonomy by creating shortcode in woocommerce?
- How Can I Display the Category Description in a Theme with no Category.php or Archive.php?
- How to add excerpt and read more button to category archive page
- Display all posts from specific category
- Meta Box: display single image on an archive-template
- Make category archives page in menu non-clickable
- Custom Category Archive Pages
- custom browse by
- How to get get_categories()’s ‘hide_empty’ argument to work with global year var in the archive template?
- How to display total views of all posts of one category?
- get_the_terms_list output last child only
- How to get related category/categories in WordPress archive page
- Category archives
- Create monthly archive for parent category
- How to count the number of monthly archive?
- Transfering static site to wordpress and retaining category by month paginations
- Conditional statements based on custom meta value in category archives
- 2 loops in archive.php (one for each category)
- Search tag within category
- Categories to A News Page
- Category Archives: Show posts categorized in parent category only
- Determine the category that an archive-page is for
- Easiest way to display post archives in category-then-alphabetical order?
- All post of child category not in top category
- how to implement next/prev within category archive?
- How to link ACF relationship field to the new Query block in Full Site Editing
- Category archive page has two URLs even when default theme is active with no active plugins
- Sorting past events by month
- Sort Category Archive pages and place sticky posts first