Theme develope featured area best practices
-
Interested in learning from those that are more experienced than me. However most guides online are aimed at non programmers and novices and do not go as in depth as I hoped.
I’m a bit lost on how to implement semi static and well defined content. One example is for a static front page on a site. I want to perhaps define a area on the front page where the user can put featured items on his site, or a list of services provided, or testimonials. I can already see a few solutions, but i’m just not certain that they are the right tool for the job. I’ll list those solutions and the reasons why I don’t think I should use them.
-
Widgets/Sidebar would work but the problem I think there is that it is for very dynamic purposes. Lets say
I’m defining a area that is only supposed to show 3 featured elements, but a user could add categories widget there,
or a custome menu. Something not designed to fit in the area. Also I would need to create a custom widget or implement
a html widget which would make editing harder for none technical minded user -
Custom page types I could create custom page types and display a loop of them in that area, I could thusly
limit the number of items, put them in a row etc. It just doesn’t feel like the right use case for Custom post types.
In my opinion it is for actual content, not a one off semi static thing like this. Reviews on a tech site, cars on
a car site, this are the things that custom post types are intended for right? -
Register settings / Customizer This one I haven’t looked enough into. Defining these things as a theme dependency
or settings in the functions.php might be the way to go. I’m thinking these are mostly one off fields instead of
a more multi element components. -
Plugin Likely there is a plugin for this exact purpose. I would like to avoid using non-essential plugins
but that might be wrong of me.
Do you understand what I’m talking about? I’m not asking for something heavily customizable, but something I can strongly define in a theme so that users can change the content of a semi static area.
This here will be a area for featured content, it will have a header, a paragraph, a icon, and a link. It will show in rows of 3 on large screens (this is of course not the problem, theme will handle displaying, just to give the idea what I’m going for).
This will be a area for testimonials, it will have a image, a qoute, a name and a twitter link. I will display this as a slider.
-
Widgets/Sidebar would work but the problem I think there is that it is for very dynamic purposes. Lets say
-
I usually do stuff like that by creating a front-page.php template file in the theme and use Advanced Custom Fields to structure the edit page for that template so there’s no “free form” editing available — just the boxes, etc. I’ve even built a slider using flexsider.js and ACF.
@sterndata Yeah Advanced Custom Fields seems to be pretty popular. But I’ve also heard it can become unwieldy in certain circumstances.
I will take a look and see how it works, thanks for the tip.
Unwieldy? I’d suspect anyone claiming that is Doing it Wrong™. Good alternatives are limited. You could build your own custom meta box(es), which is essentially what ACF does for you. You could use custom post types for at least some content. While posts were originally intended for blog entries, they are merely data container objects which we can use for any purpose where it makes sense. One example that comes to mind is testimonials. One could have a collection of a dozen or so, but only display three on the front page. You could display the latest ones, and maybe have another page linking to the remainder, or the remaining testimonials could be kept merely for archival reasons even if they are not used for display anywhere. Or you could randomly select three from the many to display differently on every request.
ACF or meta boxes make good sense in many places, but sometimes post types make the most sense. There’s no reason you cannot do both.
I was wondering about that too a few days before. Sometimes, there are some blocking situations in the development, and I do not know how to go forward within this context.
Here’s my most recurring case, dynamic contents with short and defined length, that should be call on several page, at different positions depending on them.
https://image.ibb.co/hfODhy/schema.png
I presume CPT are still the best approach, but maybe I’m missing something …
-
This reply was modified 7 years, 11 months ago by
Nox.
Static elements that occur on several pages can be managed with a partial template that’s loaded in by either a call to get_template_part() or loaded via shortcode.
What’s on that partial template again depends on the desired UI for managing content. It could be all hardcoded if it does not need to be altered by the site owner. You could utilize ACF or meta boxes or CPTs as before. You could utilize an existing post type and only show such posts that have a particular category or taxonomy term assigned.
There are basically three different means of containing and displaying page content in WP: Posts, meta data, and templates (assuming you don’t wish to create your own means through a custom table). You can mix and match these, introduce custom UIs for them, etc., but you are still only using some combination of the basic three. How you make use of them though, is only limited by your creativity.
-
This reply was modified 7 years, 11 months ago by
The topic ‘Theme develope featured area best practices’ is closed to new replies.