WordCamp 2014 Presentation Designing templates with WordPress

Sep 20, 2014

Creating WordPress templates and maintaining usability in the Admin panel. How to use best practices and reliable resources that will help you create bolder layouts without resorting to workarounds when inserting content.

Video Description [cite: 1]

The talk we are going to have now, with Herick, will touch on some very similar points regarding this issue of dashboard customization, of user-centered design. [cite: 1]

The panel is right over there for a reason — we figured there was a really cool connection. [cite: 2]

So, to get back into the rhythm of the event’s talks, let’s call our elite troop. Hit the music, Felipe! [cite: 3]

Now things are going to get serious! Unfortunately, the Wi-Fi doesn’t allow everyone to use it. [cite: 4]

And I also need to ask that when you ask questions, wait for the microphone, because since this is being recorded, otherwise there will be gaps in the audio — answers without questions. [cite: 5]

Well, guys, my name is Herick. Herick Correa, okay? I’m going to talk about template design, but I’m not just going to talk about design. [cite: 6]

Because I’m not here to teach anything, I’m not here to tell you what you have to do or what you cannot do. [cite: 7]

I’m here to try to bring a way of thinking. [cite: 8]

What I’m going to say here is to guide you to think about how you’re going to build a template. [cite: 9]

And a lot of what I’m going to say, people have already talked about here in this panel. [cite: 10]

Actually, they’ve already said seventy percent of my talk — only in a very formal way. [cite: 11]

I’m going to speak more illustratively, and I think it will be a good complement to what they said, because I brought some images. [cite: 12]

I also wanted to say that Maujó has already made a lot of money off me with his book. [cite: 13]

So, an important thing: as much as you know CSS, as much as you know HTML, sometimes it’s good to buy a book from someone you trust. [cite: 14]

I didn’t know him personally, but I trusted the whole community that spoke highly of his product. [cite: 15]

Sometimes you want to read about semantics, know what that HTML means, what that tag, that code does, why use it or why not use it. [cite: 16]

So sometimes it’s good to read this from someone reliable, because on the internet there are a lot of people saying different things. [cite: 17]

So it’s good. And it was a pleasure to actually meet him. Let’s go. The point is this. [cite: 18]

Let me introduce myself properly. Well, I already said my name. I work with the Web. [cite: 19]

I took a Web course in 2002 and, since then, I fell in love with the Web. [cite: 20]

I went to college for Design because I used to draw and thought my future would be in illustration and drawing. [cite: 21]

But it wasn’t. Everything I learned in Design college I brought to website creation. [cite: 22]

I started with FrontPage too. At that time the frameset was trendy. And then I kept evolving. [cite: 23]

But my professional career was a bit confusing, because I started as a designer, graduated as a designer, and was hired in companies as the “web designer,” the guy who did everything from the magazine ad to the company’s website. [cite: 24]

There wasn’t this division between front-end and back-end like there is today. [cite: 25]

Nowadays it’s easy — one guy does the layout and another builds it. Back then, no. You did everything. [cite: 26]

Until I ended up at an agency. When I started working at a web agency, I began to see this differentiation. [cite: 27]

I started working with front-end, because I joined as a designer, but nobody did HTML. Back then, this was kind of obscure. [cite: 28]

So much so that you were hired as an “HTML programmer.” It’s in my work record book. I have proof. [cite: 29]

So you were the “HTML programmer,” you got there and built the HTML, because there was no one to do it. [cite: 30]

You did design. I worked in an agency where there was no HTML, no back-end, no front-end. [cite: 31]

Neither back nor front. So, since I was alone, I had to pick an option, a tool. [cite: 32]

And since I already knew WordPress, I think since… Over time, I was forced to think more about the client — which is the big idea of this talk here. [cite: 33]

Which is the following: you go to the client and they say: “I want to change that alert phrase ‘Your email was successfully sent.’ I want to put: ‘We will reply shortly.'” [cite: 34]

Then you say: “Oh, you can change it. It’s inside Appearance, in the widget. There’s a widget there called Alert that I created.” [cite: 35]

No. You are not going to do that. You are going to create an area in the admin menu. [cite: 36]

And in that area there will be something like “Settings”, “Options”, or “Site Texts” — you choose. [cite: 37]

And there it will have “Alerts”, “Title of something”, or “Title of some area”. [cite: 38]

The intention here is to make you think both about the development part and the client’s experience. [cite: 39]

Because you are not going to go to the client and say they have to mess with a widget. [cite: 40]

They won’t know how. The ideal is perhaps to hide this part, so the client doesn’t even see it. [cite: 41]

Like Richard said: you use the Admin Menu Editor and hide this part, because I think the client shouldn’t mess with it. [cite: 42]

Because just as you left the widget showing, you left the menu part showing. [cite: 43]

Left other parts showing, like the template editor — those things. [cite: 44]

That is not what the client should be touching. They should only touch what they need to touch. [cite: 45]

If they need to handle an update, they either call you, ask you, or you send it. [cite: 46]

You can even say: “Look, you have this admin login here, which you’ll use to work on the whole site. But please, when you log in with this one here, only touch this part.” [cite: 47]

That way, they can update WordPress. So, it’s important to create a hierarchy. [cite: 48]

But to create this hierarchy, it’s also important to create an area — a friendly environment for the client. [cite: 49]

That’s the idea. And as they said here — and this talk was ready before they spoke —, it seems to be a universal concept: everyone thinks WordPress is a limited tool. [cite: 50]

But that is a lack of knowledge. As it was said here: it’s not limited. Sometimes, the limitation is in the knowledge. [cite: 51]

Sometimes you don’t know how to do something. But then you go on Google: “plugin to do such a thing.” [cite: 52]

Man, there’s going to be a plugin. Someone already screwed up before you. [cite: 53]

You can be sure that, especially in WordPress, someone already got screwed before you, created a solution, and turned it into a plugin. [cite: 54]

And it’s very simple: you take the function you made — which you would usually put in functions.php —, throw it into a plugin, and you’re done. [cite: 55]

Saved another person’s life. So, it’s not limited. [cite: 56]

Maybe it’s you who hasn’t searched properly on Google for what you needed. [cite: 57]

Well, now, starting the creation part… I, as an interface designer, whenever I’m going to create a template, I have to think. [cite: 58]

Because, usually, whoever works with front-end or back-end and takes someone’s template, thinks like this: “How am I going to build this site? I’m going to build it in Bootstrap, set up these areas here…” No. [cite: 59]

That’s not what I’m talking about. [cite: 60]

I’m not here to say how you have to do your HTML. I’m here to try to show how you have to think about it — both on the front and back — in a way that is extremely friendly for the client to handle as well. [cite: 61]

For example, this was a site I made. (And I don’t know how to use this laser here…) This was a site I made. [cite: 62]

The client hasn’t updated the site yet, so, if you try to take this presentation and go there, you will still see a lot of lorem ipsum. [cite: 63]

But that’s okay. It serves our purpose. It was like this: I designed this site for the client. [cite: 64]

And, when building it, I created the following areas, okay? [cite: 65]

I created the highlight part, this here is inside “about”, and this here is the post category. [cite: 66]

In other words, at the time I thought: “Well, can I pull this here as a post?” I can. [cite: 67]

But what if she wants to feature something else? [cite: 68]

Am I going to create a category where I say it’s a post? [cite: 69]

Or am I going to create a category just for highlights, and all the posts that are also in this highlight category will appear there? [cite: 70]

No. That’s wrong. Why? Because, inside the post, if she wants to talk — like: “Here in England, it’s the Queen’s National Week” — and wants to make a post about it as a highlight, she will have to create a post that is not a product, and say it’s a highlight. [cite: 71]

That’s confusing. So, what do you do? You get a plugin like Advanced Custom Fields and create an area. [cite: 72]

It has an add-on called Options, where you can create sections within your menu, and inside those sections you can create sub-items. [cite: 73]

For example, I usually create an area called “Additional Content”, or “Complementary Content”, or even “Options”. [cite: 74]

And then I create an area called “Highlights”, and inside “Highlights” the person adds this right here, you see? [cite: 75]

She doesn’t need to create a post for that. She can create this content right here. [cite: 76]

ACF allows you to link this image, or this content, to a post if you want. [cite: 77]

But it is much easier for the client to create it this way than having to remember that, to be a highlight, it needs to be placed in a category, that it can’t be “product”, it has to be “highlight”, etc. It’s confusing. [cite: 78]

Here, I put this inside the “about” page. And this is another thing I’m going to talk about: how to get content from a specific page, even if it’s not the main page. [cite: 79]

So, even if this doesn’t appear inside the “about” page, when you click on the link for that page on the front-end, this content doesn’t show up. [cite: 80]

This is content that I created just for the home page. But it’s inside “about”. Why? [cite: 81]

Because it’s on the “about” (or “about us”) page that this content should be. This content is “about”. [cite: 82]

So, the client understands that they will have a field to write, to place a video, they will have a field to place a testimonial, and to write about each of these three topics here. [cite: 83]

They will understand what to do more easily. And here is the normal post category. [cite: 84]

What I want to show is that when you take a layout to build — a template —, it’s not enough just to think about how you’re going to write the HTML. [cite: 85]

Because HTML is the least of the client’s worries. And they are paying. [cite: 86]

So, for them not to keep calling you… I know because I’ve been working with this for almost ten years… And, man, they call. [cite: 87]

Now, with Facebook being super BFF, you know? The guy pings you. It’s ten at night: “Are you awake?” [cite: 88]

And you: “I am.” Believe me: you have to answer. Because you are a freelancer. Your great differentiator is not having fixed hours. [cite: 89]

The client doesn’t need to call you from nine to six. [cite: 90]

It’s okay, if he calls you and you’re sleeping, you won’t answer, you’ll call back later. [cite: 91]

But the great differentiator of being a freelancer is this direct service with the client. [cite: 92]

The client knows they can reach you at any time. This provides security. [cite: 93]

If he pings you at ten at night on Facebook, you have to answer. And there’s WhatsApp too, you know? [cite: 94]

WhatsApp is blowing up. Turn off the sound, turn down the volume of WhatsApp because it’s complicated. [cite: 95]

But anyway, that’s cool, because you can chat, and it also brings a certain informality to the relationship with the client. [cite: 96]

So, sometimes you can even drop a casual word — and the guy won’t be shocked — because he knows you’re there, having an informal chat. [cite: 97]

But anyway, he will ask you. If you don’t make something intuitive, he’s going to ask you. He’s going to call you. [cite: 98]

He’s going to wake you up. That’s why it’s important that we… This site was an experience, because it used… it used a lot of custom content, used a lot of WP Query, used a lot of Custom Fields, and we also worked with many different categories. [cite: 99]

So, for example, the other day they asked me how I would make one category different from another, because if the category is just a page, how am I going to change it? [cite: 100]

How am I going to have a design for category X and another for category Y? [cite: 101]

That was cool too, because I managed to work that out in this template. As I said, I created a Highlights area. [cite: 102]

You have the News part, which is the normal posts part. [cite: 103]

Since they wouldn’t have a blog in the future, I worked the news parts as if they were posts — but I used a plugin in the admin to rename “posts” to “news”, because if the grass color changed, the animal would starve. [cite: 104]

Even though this client was very smart — the guy who managed this site was very smart — he understood without needing much explanation. [cite: 105]

But not every client likes to understand. They don’t read. They don’t want to read. [cite: 106]

Even though Advanced Custom Fields allows you to write what each of the fields means — you can describe: “here you put this, this, and this, which will appear there, there, and there” — they won’t read it. [cite: 107]

He will say: — “Herick, what is this here?” Then you will repeat the exact same words. [cite: 108]

Everything written there, you will repeat. He will say: — “Ah, that’s right. It’s right here, look.” [cite: 109]

— “Man, I didn’t see it.” — “Yeah… that font is a very light gray, sometimes it’s hard to see.” [cite: 110]

Man, you’re there for that, right? So, in this case, I set it as a post, created a custom post, another custom post, and there are several custom posts on this site too. [cite: 111]

I think I’ll show his menu shortly. Well, the front-end… In the old days, you had that blog, which was the face of WordPress — that blog with a bunch of posts (pardon the word), and with that “see more” button. [cite: 112]

So, you had that listing, as if it were the initial identity of WordPress. That started changing. [cite: 113]

Nowadays you have calls to action, highlights, JavaScript slideshows, sometimes image grids — like an image panel. [cite: 114]

This changed, but it also raised doubts for those who are going to build it. [cite: 115]

Like: “How do I call two categories on a page that isn’t the category page?” [cite: 116]

The guy clicked on “Home”, which is a starting page, but how do I call two categories there? [cite: 117]

How do I make a post of something else I want appear? [cite: 118]

How do I make content, edited by the client, appear on all pages without having to use WP Query all the time? [cite: 119]

So, questions arise that I will try to solve with what I’m going to say now. [cite: 120]

First of all, you need to know WP_Query. I know I was asked — Google commented to me not to do something so technical — but this is a very nicely summarized way of how you do this. [cite: 121]

There is no way to be more flexible on this point, you know? And since people here have already talked about layout in a very generic way, I think I can even get a bit more technical in this talk. [cite: 122]

So, here we go: You need to know how to work with pre_get_posts, because with it you can do the most basic things — like changing the order of the posts, which WordPress, by default, doesn’t allow. [cite: 123]

You can’t say you want it to appear by date or alphabetically. So, what do you do? [cite: 124]

You need to understand this here. Because sometimes, with one line — a single line of code — you change the order of the post. [cite: 125]

With this code right here, which I took from the WordPress Codex — a simple code, okay? [cite: 126]

Here it’s a bit more refined, because it already brings an HTML example, already gives an echo there… But with this, you can call a post that shouldn’t be there, you can call a category that wasn’t supposed to appear on that page, you can integrate things that weren’t supposed to be there… and they become present. [cite: 127]

Just don’t forget the following: once you open WP_Query, you need to reset it. [cite: 128]

This is important, because otherwise you can’t close this query and it might end up causing problems with the rest of the content that should appear below — which is sometimes the original page. [cite: 129]

So, here you only open a block to show what you wanted to show, and close it. [cite: 130]

Because if you don’t close it, it will cause problems. It’s not that it might cause problems — it will. [cite: 131]

Here I give some examples from an old site I made. [cite: 132]

In it, I took the first post of a category and gave it a bigger highlight. [cite: 133]

And in the other three positions? One of the doubts was: — “If I already grabbed the first post, how am I going to grab the next three without repeating the first one?” [cite: 134]

Then you start studying the arguments you can pass in WP_Query. [cite: 135]

For example, here I took the most recent posts from categories 2, 5, 4, 6 and 8, but limited it to 1 — so the most current post from all these categories will appear here. [cite: 136]

Then, I used offset, which means: I want it to skip the first one. [cite: 137]

In this case, I used offset 1, meaning it will skip one — the first one — and display the other three. [cite: 138]

These aren’t the same categories here, because I just wanted to give a usage example. [cite: 139]

Because you can also do this: you can take the categories, turn them into an array and display them. [cite: 140]

It will depend on your use case, how you access these categories and your project. [cite: 141]

Here there’s also another category argument — it’s the same thing, but a bit more complete. [cite: 142]

Could you do this with CSS? Grab the :first-child in CSS? You could. [cite: 143]

But for some reason, I thought it better not to, because of the image size. [cite: 144]

The image weight is important. In this case here, I loaded a larger image, I allowed myself that. [cite: 145]

Here, I grabbed smaller images in the other blocks, which makes all the difference when you’re working with something that might appear on a mobile or tablet. [cite: 146]

So, whenever you can reduce the weight, sometimes it’s better to run another SQL query than to load a large image that, instead of being 12 KB, will be 50 or 60 KB. [cite: 147]

I think it’s more costly. So, in this case, I did it this way for that reason. [cite: 148]

— “But in the example you gave, on the left, the highlight has categories 2, 5, 4, 6 and 8. And below, 2, 5 and 4. You couldn’t do that with CSS.” [cite: 149]

No. But actually, here I just used it as an example. [cite: 150]

In this case, the categories were the same — I just put it to give an argument example. [cite: 151]

Here is just another example of image weight. [cite: 152]

Well, now let’s start talking a bit about how to build the backend. [cite: 153]

I don’t even know if I’m going too fast. I don’t even know the time. So, what happens? [cite: 154]

As I told you guys: let’s talk about the backend. And the backend has to be friendly. [cite: 155]

I’m repeating this because it’s very important. You guys already saw that you can build — like the folks said here — you can build whatever you want in your template. [cite: 156]

Your template will be there, set up. You will be able to do it in the backend, pull all the posts you want, do everything. [cite: 157]

But if you have to create a document for the client to understand what you did, that’s not cool. [cite: 158]

Let’s start thinking about the backend for the client too. [cite: 159]

Everything you do on the front-end — like a highlight area, a grid area, a JavaScript slide… — all of that, you have to think about how you’re going to do it in the admin, in the dashboard. [cite: 160]

Because if you have to keep explaining everything to the client — everything they have to change, how they alter the data — you’re screwed. [cite: 161]

They will reach out to you, call you, talk to you… You will end up giving them a WordPress course. [cite: 162]

And worse: you’ll give this course at 10 at night… on Facebook! Or on Skype too. [cite: 163]

Skype is also booming. So, I’m going to talk here about three plugins that are very interesting. [cite: 164]

There’s Advanced Custom Fields, which I’ve been talking about here for a while. [cite: 165]

For me, this should be in the WordPress core. I might be talking nonsense, but making WordPress without it makes no sense. [cite: 166]

That “admin” option is in the editor. By the way, the guy who created this plugin is really nice. [cite: 167]

I don’t know if his name is Yannis or Janis, I don’t know. [cite: 168]

But at the Meetup we had in August, he gave us three licenses to raffle off. [cite: 169]

One of the winners is even bugging me, because I forgot to send the license. But it’s in the email, rest assured. [cite: 170]

He was super cool. He said: — “Man, take three licenses here. When WordCamp happens, let me know and I’ll send more.” [cite: 171]

I ended up forgetting to let him know… but I’ll try to talk to him again. It’s a lot of stuff to do. [cite: 172]

And since this talk is probably going to WordPress.tv, I even wanted to publicly thank the opportunity he gave us to distribute these licenses. [cite: 173]

And I can show this plugin to more people too, which is very cool. [cite: 174]

I was even going to change the talk to remove the custom post type part and put WP Generate, but I thought it would be a bit too advanced. [cite: 175]

I thought I would have to explain better how that site works, so I think maybe the custom post type is a friendlier way to work with personalized content. [cite: 176]

The Pulsar Constype plugin allows you to create areas in your admin that you didn’t have before. [cite: 177]

You don’t have to be stuck to “post”. One of the things everyone does at the beginning is: post, category… then it’s in the “highlight” category, then it’s in “home highlight”… and then you start creating a bunch of logic based solely on categories. [cite: 178]

And you don’t need to go through that. Actually, for a long time you haven’t needed to go through that. [cite: 179]

And today, even less so, because clients are more demanding. [cite: 180]

So you can create a post type called “video”, you can create “previous editions”, “photos”, “job openings” — as is the case of the union’s website menu. [cite: 181]

You can create specific areas. You can make the client understand. [cite: 182]

And anyway, now you can have these areas without having to explain everything to the client. [cite: 183]

Because when they open the admin and see “Videos”, they will click on “Videos”. They won’t click on “Post”. [cite: 184]

They will click on “Videos”. — “Wow, cool, it got modernized. There are videos here!” It’s more or less like that. [cite: 185]

It’s the simplicity of the thing that makes all the difference. Now, let’s move on to the Admin Menu Editor Pro. [cite: 186]

The “Pro” is because there’s the standard version, which is free — but, honestly, I don’t think it works very well. [cite: 187]

I’ve had problems with it. I don’t know if it improved. But after I started using the Pro version, I never went back. [cite: 188]

Because the Pro has the following difference: in the free version, you change it for everyone. [cite: 189]

Something you hid here, for example, “Tools” — which is something I hide right away… — Hello Herick, my name is Felipe. [cite: 190]

I’m a director at Digital Terrain. Herick, from what I understand of the system you presented, there is no need to create a kind of manual for the client. [cite: 191]

You focus so much on the admin, in such an intuitive way, that it explains itself. [cite: 192]

The client can follow along and make the changes without needing any additional instructions. Is that right? — No. [cite: 193]

Actually, the following: you will have to give instruction, because… imagine — I think like this — imagine your father, who is seventy years old, is not used to handling this. [cite: 194]

Then he logs into that thing and thinks: “Man, what is this? What do I do?” I like making videos. [cite: 195]

A video using screencast. I like doing that: teaching the guy to do it the right way. [cite: 196]

But the fact that it’s a friendly dashboard means the guy will only need to watch the video once, because later he will remember everything you explained, because it’s all right there, you know? [cite: 197]

If in the video you tell the guy that he has to go to “Appearance > Widgets > Sidebar 3” to change an alert, every time he wants to change that text, he will have to remember that path. [cite: 198]

It’s different if you have an area called “Change Alert”. [cite: 199]

He might not even remember what the first text or the first alert was, but you already told him: — “Look, here you change the text that appears on the screen.” [cite: 200]

So every time he looks at that menu item, he’ll know that’s it. [cite: 201]

In other words, it’s not that you avoid making a manual, you just avoid repeating the same thing over and over, you get it? [cite: 202]

I think that’s what’s important. And that’s where the ease of a clean admin dashboard comes in, right? Yes. [cite: 203]

The fact that you reduce this kind of thing saves lives. Is that the plugin you recommend? [cite: 204]

There’s also Adminimize. Do you know it? So, Adminimize and Admin Menu Editor clash a bit. [cite: 205]

If I’m not mistaken, Admin Menu Editor prevails over Adminimize. But it’s up to you. [cite: 206]

Adminimize hides a lot more stuff than Admin Menu Editor. So, it’s your choice. [cite: 207]

I prefer Admin Menu Editor because Adminimize doesn’t let you rename items, and this one does. [cite: 208]

So, I think… I’m not doing an ad for the plugin, okay? I’m just saying that for me, it helps a lot. [cite: 209]

Whether it will help you or someone else, I don’t know. But for me, it works. [cite: 210]

And I think it’s worth it. It’s almost a core WordPress plugin, because everyone installs WordPress and immediately runs to install it. [cite: 211]

It’s very easy to use, very simple. And there isn’t much to say about it. [cite: 212]

I believe everyone who works with ACF already knows it. [cite: 213]

It’s a plugin that allows you to add fields to your posts. [cite: 214]

Meaning, you don’t need to insert a gallery block just to be able to add a photo gallery to your post. No. [cite: 215]

You use ACF, and inside your post you put an “Add Photos” field. [cite: 216]

It gets much easier for the client to understand than using that short tag. [cite: 217]

The guy creates a gallery in NextGen Gallery, copies a short tag and pastes it into the WordPress text field? [cite: 218]

No. He’s not going to do that. He has a field in the post saying: “Insert photos.” Done. [cite: 219]

And the coolest thing is that it has an add-on called Options, which allows you to create subpages. [cite: 220]

I even put the code here that it uses. In this case, I created a content section called Complements. [cite: 221]

And inside “Complements”, I put: Top highlights, Documents for download, Contact address. Because, for example, the contact address is something that appears repeatedly in the footer. [cite: 222]

Social networks too — they appear in the top and footer, constantly. So, I left this here for the client to fill out. [cite: 223]

Because generally, when the client asks for a website, they don’t even send you their Facebook link right away. [cite: 224]

In fact, they hardly send you anything right away. So, you leave everything for them to edit. Everything. [cite: 225]

Sometimes the email they send you, they haven’t even created yet, because you haven’t set up the server for them yet. [cite: 226]

Then what happens? You just leave the email field there. [cite: 227]

The address — sometimes the guy doesn’t even have a store yet, so you don’t even know what address to put. [cite: 228]

So, leave it open for him to edit too. Sometimes he wants to change the phone number, add a cell phone… so, Options is cool. [cite: 229]

It’s a paid add-on, but it’s cheap. And it’s worth it, because you can make the content appear on all pages. [cite: 230]

You don’t need to program anything. It’s just a little call. The field, you know? get_field(‘field_name’, ‘options’) — and you’re done. [cite: 231]

This field will appear on all pages where you call it, for example, in footer.php. [cite: 232]

It will always be there. It’s very easy to add additional content. For example, here I put “Complements” and “Top Highlights”. [cite: 233]

Easy. The client knows that’s over there on the home page. [cite: 234]

And if he wants to use these highlights on several other pages, it’s all in one single place. [cite: 235]

He doesn’t need to keep using WP_Query to keep calling the highlight posts on every page, in a loop. [cite: 236]

He doesn’t need to. This right here solves it. Here’s roughly how it appears. [cite: 237]

So, you have: phone, email, alerts (as I said, I put it here too), links to social networks… You also have a repeater field — meaning, if the guy wants to add several social network links on demand, he can. [cite: 238]

So, this here is a lifesaver. And finally, the file hierarchy — which is very important too. [cite: 239]

When I said you can have a category with one layout and another category with another layout — which was a question I was asked recently — what happens? [cite: 240]

It’s very simple. Even when I explained to the person how to do it, they said: — “Man, is that it? You don’t need to write anything?” [cite: 241]

No. It really is simple. Did you create a category called photos? Then you’re going to create the file category-photos.php. [cite: 242]

— “Ah, but I put event-photos as the slug for my category…” Okay. Then it will be: category-event-photos.php. Done. [cite: 243]

Every time you access the “event photos” category, WordPress will check if this file exists. [cite: 244]

If it exists, it will display the HTML you prepared. If it doesn’t exist, it goes to the default template. [cite: 245]

Meaning, you don’t need to create one for all categories. You only create it for the ones you want to differentiate. [cite: 246]

For the others, let it go to category.php. This was even a talk that Guga Alves gave, talking about file hierarchy. [cite: 247]

Later on, I’ll even share the PPTD link — it’s interesting material. [cite: 248]

In other words, this applies not only to categories but also to individual posts (single) and pages. [cite: 249]

If you want a single post to look different, you put single-slug.php or page-slug.php. [cite: 250]

And only that page will have that differentiated visual. This is for those who want to make more elaborate layouts, where each category has a listing and a different appearance. [cite: 251]

That’s how it works. For example, here I put an example where we have: “News” category page, “Photos” category page. Both are categories, they are listings. [cite: 252]

But here I put one layout, and there I put another. [cite: 253]

You can clearly see how you can have total control over each page. And I think that’s it. [cite: 254]

— Herick, going back to the previous slide… you were talking about customized pages for categories and singles. [cite: 255]

You talked about customizing the single for a specific post, but what about when we want to customize all posts from a certain category? [cite: 256]

Is there an ideal solution for that? — Look, I’ll tell you that I even talked to Guga about this at the time, because I had the same doubt. [cite: 257]

I think, in terms of files, there isn’t. You will have to use PHP there, you will have to try to decode… It could be that I’m wrong, because this already gets into a more technical part than I’m used to using. [cite: 258]

Maybe someone here can complement this better. But what I believe is that you need to identify the post’s category, and from there, apply a visual — maybe throw that into a variable — and with that variable pull a specific CSS style, or even use an if condition to load a different layout. [cite: 259]

This will require some sort of programming, because there is nothing predefined in WordPress that automatically links a single.php to a category just by the file name. [cite: 260]

— Herick, good afternoon. You were talking about personalization. Can we also personalize the header and footer in the same way? [cite: 261]

Do you put the header name, the category name, and it pulls it too? [cite: 262]

— She’s talking about pages within the category. It can be done too. [cite: 263]

You can, I don’t know exactly from memory right now, but yes, it can be done. [cite: 264]

It can be done for archive, it can be done for blog. [cite: 265]

Every page you put inside the category, it pulls it too. [cite: 266]

About what she said — a specific single for a certain category — maybe this is it: you have the “photos” category, and you want all posts in this category to use a given template. [cite: 267]

Is that it? She was trying to link a single post page to a category. [cite: 268]

So, in this case, as you said, there isn’t a specific file for this in the template hierarchy, as there is for other situations. [cite: 269]

But what can be done — which I’ve already done in a project — is the following: In single.php, you insert a code that identifies the category. [cite: 270]

And then do an if: — “If it is from the photos category and a single-photos.php file exists, load this file. If it doesn’t exist, load single-default.php.” [cite: 271]

Yes, you do that with get_template_part() and ask to include the file. [cite: 272]

Then you create single-photos.php to bring all posts from the “photos” category, single-videos.php for those in the “videos” category… And when it isn’t either of the two, it loads the default, which shows the post for all other categories. [cite: 273]

In the end, you are going to need some direct intervention in the code. There’s no magic at this point. [cite: 274]