zhaoJian's Tech Notes

WordPress Using Different Templates for Different Categories or Pages

Technology ~708 words · 2 min read - views

How can you use different templates for different WordPress categories?

How can you use different templates for different WordPress pages?

Searched for a long time but couldn’t find the reason. Previously I would create a page-name.php page, but it wasn’t convenient.

Today I googled it and found on a foreign website that there’s actually such a convenient method.

That is:

page-id.php

category-id.php

or

page-slug.php

category-slug.php

This format is convenient and simple. It’s just not as convenient to find in the folder as before, but it’s okay. Will use this method from now on.

The specific usage is: if page 1’s id is 1, page 2’s id is 2, then create two files page-1.php and page-2.php

Share:

Comments