A
A
Alexander Nameless082018-05-15 13:35:03
WordPress
Alexander Nameless08, 2018-05-15 13:35:03

How to make two templates for categories of wordpress post types?

Hello!
The site has a blog and a bibliography. In both sections, the user should be able to add categories himself. For these sections, the layout for displaying previews of posts in the category is different. That is, all blog categories have one template, all bibliography categories have a second template.
Created a custom post type bibliography. Blog respectively in standard wp posts. But how now to make one template for all categories of the blog, and another for the bibliography?
By tags or id (category-slug.php -> category-id.php -> category.php -> archive.php -> index.php) is not suitable. the user himself will create categories.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan Hasanli, 2018-05-15
@Nameless08

Hello!
In theory, you should have a separate taxonomy for the bibliography, and for this taxonomy you can create your own template archive-post_type.php or category-post_type.php
It may be that you have 2 post types: posts and bibliography, and one is attached to them standard taxonomy of categories, then you probably need to arrange a check inside the template and, depending on the type of post, display the desired template.
Also a link to a useful source - https://codex.wordpress.org/Post_Type_Templates
archive-{post_type}.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question