With the introduction of format sorts in WordPress, the flexibility to publish “Hyperlink” posts or “Gallery” posts , and many others. turned one thing you can do out of the field.
However in the event you’ve ever needed to provide totally different posts a method of your personal, there are a pair methods to perform this—with a little bit of customized coding, or by utilizing a plugin.
We’ll have a look at each on this publish.
Proceed studying, or use the hyperlinks beneath to leap to any part:
First up, let’s…
1. It’s a good suggestion to make a duplicate of your website earlier than twiddling with information and code, so go forward and do a fast backup now.
An excellent host will seemingly have a built-in backup characteristic that you may avail your self of. In the event you host with WPMUDEV, you’ll be able to run a fast backup via The HUB. Alternately, you can use a plugin (we advocate Snapshot Professional).
Push-of-a-button backups by way of WMUDEV’s The Hub Interface.
2. Entry your WordPress website information, both by yourself server, or via your host entry level.
Accessing WP website information via WPMUDEV’s Hub is a swift, streamlined expertise.
3. Navigate to: Recordsdata > wp-content > themes > twentytwenty (or no matter theme you’ll be utilizing)… and find the single.php or singular.php file.
4. Make a duplicate of this file, then rename it. I’m going to name mine: jbtest.php.
Creating and enhancing a php file in WordPress.
5. Now we have to transfer this file into the templates subfolder (underneath twentytwenty).
You’ll be aware that the information already populated listed below are preceded by “template–”, so we’ll rename the file once more to match that conference, making mine: template-jbtest.php.
That is how the folder and information have a look at this level.
Now that the file is known as appropriately and within the appropriate folder, we have to edit the contents so it’s coded as a template.
6. Go into enhancing mode (right-click the file, and select Edit textual content), and on the very prime of the code, add the next:
* Template Identify: JBTest
* Template Submit Sort: publish, web page
The place the code reads “Template Identify Posts: JBTest”, use no matter identify you want (rather than JBTest).
Observe: Ensure every line of this prime degree code is by itself row. (It could show in a single line whenever you paste it.)
7. Change the remainder of the file in no matter means you want, to make it your personal. Ensure to click on “Save & Shut” after finishing the edit.
I added some random “testing” textual content additional beneath, as a visible validation that the code labored.
Let’s create a brand new publish, so we will take a look at out the template we simply made.
1. From the WordPress dashboard, create a New Submit.
2. In the best aspect menu, you need to see a column referred to as “Submit Attributes”, with the header “Template” beneath it.
3. Click on on the Template dropdown menu to see the numerous templates obtainable. Your new template will likely be listed there as you named it, so go forward and choose it!
Create your publish and put it aside, or just save and preview to get a have a look at it.
Preview of a New Submit made with my customized template.
There’s my “take a look at” message. It’s not very fairly, however that’s simply mounted by formatting, similar to including padding, altering font sort, model, coloration, and many others. The necessary factor is, it undoubtedly did what we needed!
Now, let’s strive the plugin methodology.
In the event you don’t wish to contact any code, you’ll be able to decide to go the plugin route. On this instance, we’re going to make use of the Customized Layouts plugin.
Head to the WP plugin repository to get the Customized Layouts plugin.
Customized Layouts plugin.
2. After putting in and activating the plugin, you’ll see its menu within the dashboard. Click on on Templates, then the Add New Template button.
Customized Layouts plugin, add a template.
3. This can open the Template enhancing mode, which works with Gutenberg blocks by way of the left aspect of the display.
You possibly can work from the Template or Component tabs, accessible on the best aspect of the display. Ensure to call your template, and put it aside when full.
Customized Layouts plugin, Template enhancing mode.
4. It can save you this as a template for any future posts, or use the shortcode (furthest proper aspect panel in enhancing mode) to show a single occasion of the template.
In the event you choose, you’ll be able to work from the Layouts menu, which permits for simple setup of grid sort posts. All the pieces you do right here may also be saved as a template for future use, or by utilizing shortcode to show the format.
Customized Layouts plugin, Structure enhancing mode.
5. You possibly can View, Edit, or Delete Templates or Layouts at any time from the dashboard plugin submenus.
Customized Layouts plugin, saved templates record.
There you’ve got it… two comparatively fast and straightforward methods to provide particular person posts a singular model.
For individuals who notably take pleasure in DIY, try this in-depth article on the weblog, Creating Customized Content material in WordPress: Customized Submit Varieties.
Editor’s Observe: This publish has been up to date for accuracy and relevancy.
[Originally Published: November 2011 / Revised: April 2022]