Amit Kumar
Amit Kumar

Reputation: 1

How can I set custom page for each category and its subcategory in WordPress?

here is an example i have set the category as fruit->red->apple and i want to set custom pages for apple.

I tried adding file in my child theme copping the codes from category.php and making the new file as apple.php and made some modifications to it but it didn't worked out

Upvotes: 0

Views: 226

Answers (1)

amarinediary
amarinediary

Reputation: 5449

If you're are using the default wordpress post category, then this is what you're looking for: category-apple.php you just have to duplicate your category.php file and customize it has you want.

If you're are using a custom taxonomy, then this is what you're looking for: taxonomy-fruit-apple.php you just have to duplicate your taxonomy.php file and customize it has you want.

These files let you target specific taxonomies or specific taxonomy terms. For example:

taxonomy-{taxonomy}-{term}.php
taxonomy-{taxonomy}.php
tag-{slug}.php
tag-{id}.php
category-{slug}.php
category-{ID}.php

You can learn more about the taxonomy.php file @ https://developer.wordpress.org/themes/template-files-section/taxonomy-templates/ You can get a better understanding of how the wordpress template hierarchy works @ https://developer.wordpress.org/themes/basics/template-hierarchy/

vEdit 1.1

Upvotes: 1

Related Questions