Chances are you’ll know you can create templates in your class pages with a purpose to make them distinctive. For instance, you probably have a class titled “Music,” you may make a template for that class (category-music.php) you can then type in a different way.
However what in case you had 5 classes that you simply needed to look a technique, 5 different classes you needed to look one other, after which 5 extra you needed to look yet one more. Despite the fact that you solely had three completely different designs, you would wish to make fifteen separate class templates, one for every class.
Proceed studying, or soar forward utilizing these hyperlinks:
A Less complicated Answer
Fortunately, there’s a less complicated resolution – a plugin referred to as Customized Class Templates that permits you to create a number of class templates you can apply time and again as you’ll a Web page template.
So in our instance above, as a substitute of constructing fifteen completely different templates, you’ll solely have to make three, after which apply the right template to the right classes.
Be aware: Though WordPress.org states that this plugin is outdated, we examined it not too long ago [March 2022] and it labored tremendous.
Methods to Make a Class Template in 4 Steps
The plugin itself could be very easy; nevertheless, some might not know easy methods to make a class template, and so we’ll go over that first. Should you already know easy methods to make a class template, you possibly can skip to the underside to see the plugin in motion.
You will have to create these class templates in your server.
Step 1: Copy Your Class.php File
Within the folder of your theme (wp-content/themes/theme-name) discover the file titled class.php. (Be aware: some themes don’t appear to incorporate this file, so be sure that your does.).
Open it and replica the contents, so you should use that as a place to begin in your new class template.
Step 2: Create a New Class Template File
Create a brand new class template file and title it one thing descriptive. It MUST begin with the phrase “class” after which a hyphen (“category-“). Additionally, it MUST finish with a “.php” file extension.
In my instance, I’m going to place a banner in my template to make it completely different from the opposite classes, and so I’m going to call this class template “category-banner.php.”
(NOTE: Ensure you don’t title the file the identical as a class in your web site.)
Step 3: Paste Contents from Authentic Class File
Now, open the brand new file you’ve simply created (category-banner.php) and paste the contents out of your unique class.php file into it.
Then, on the VERY TOP of that file, BEFORE EVERYTHING ELSE, put the next code with an applicable title in your template. (In my case, I’m going to call this template “Banner.”)
* Class Template: Banner
Your file ought to look one thing like this.
Step 4: Edit Your New Class Template
Now you possibly can edit your new class template to make it as you want.
On this instance, I’m going so as to add a banner to this template. Because of this the banner I put in will present up on each class web page that will get assigned this template.
Right here’s the banner I’m including to my template.
The Class Template Plugin in Motion
Now that we now have the plugin activated, and we’ve made a brand new class template, we are going to see choices to decide on the class templates 1.) after we create a brand new class, and a couple of.) after we edit present classes.
Making a New Class
The choice to decide on a template in your class seems on the backside of the left-hand aspect once you create a brand new class. (Posts > Classes)
Modifying Current Classes
The choice to decide on a template additionally seems on the backside of the web page when you find yourself modifying an present class.
And right here’s the results of my banner template take a look at.
NOTE: These templates type solely your class pages – e.g. mysite.com/class/music. They don’t type the person posts within the classes. To type customized taxonomies, strive the Customized Taxonomy Templates plugin from the identical plugin developer.