R
R
RNB2016-02-02 21:14:51
WordPress
RNB, 2016-02-02 21:14:51

Wordpress - what strategy to choose for working with templates for a specific section?

Background: I'm just starting with WP, before that I always made sites on different MVC frameworks.
A simple task: on the site you need to create 2 + N sections
1 section - "About us". Pages in this section: "About the company", "How cool we are".
Section 2 - "Cats". Pages: "White cats", "Red cats".
Section 3 - ... etc.
+ all sorts of different pages that will have a different number of blocks and design (this is the issue of templates for Pages).
Required functionality: go to the section, see the introductory text of this section and then a list with links to the pages of the section.
We go to the page of this section and see: the information of this page + in the sidebar, again, a list with links to the rest of the pages of the section.
As I understand it, there are 3 options
1. Do it using the Pages post type. Apply Page Templates.
Pros: problem solved. Cons: If you make Page Templates global, then users can (in theory) do something and choose the wrong template for the page. If done in a targeted way, then this is an endless copy-paste.
2. Do with Posts + categories.
Not quite yet understood how to select/create a template that will be applied to all posts with a certain category.
I found a couple of options, but they are muddy and tied to a bunch of IFs in the function file. = the more categories and sections, the more disgusting this condition code will be.
3. Make your own custom post type for each section
Wouldn't that be an overkill? But no problems, everything should work as far as I can tell.
Question: how to do better and more correctly?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Vorotnev, 2016-02-02
@Realnewbie

Option 1 IMHO. If we are talking about several "sections", but in fact parent pages, with several kids. 2nd option - a crutch. The 3rd makes sense when custom post type requires autonomy, own taxonomies, a separate url structure, a common UI for metadata, flexible requests, and so on. Well, usually when there are more than 2-4 elements in this post type.
As for page templates and "copy-paste" - it's not entirely clear what you mean, what are the concerns. Detail this problem, I'll try to suggest.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question