With the creation of structure sorts in WordPress, the power to put up “Hyperlink” posts or “Gallery” posts , and many others. changed into one thing you need to do out of the field.

However for those who’ve ever sought after to present other posts a mode of your personal, there are a pair tactics to perform this—with somewhat of customized coding, or through the use of a plugin.

We’ll take a look at each on this put up.

Proceed studying, or use the hyperlinks underneath to leap to any phase:

First up, let’s…

Create A Customized Put up Template With Code

1. It’s a good suggestion to keep a copy of your web site ahead of fidgeting with recordsdata and code, so pass forward and do a snappy backup now.

A just right host will most likely have a integrated backup function that you’ll be able to avail your self of. In the event you host with WPMUDEV, you’ll be able to run a snappy backup via The HUB. Alternately, you need to use a plugin (we suggest Snapshot Pro).

Backup files in the Hub
Push-of-a-button backups by way of WMUDEV’s The Hub Interface.

2. Get entry to your WordPress web site recordsdata, both by yourself server, or via your host get right of entry to level.

The Hub, view-edit files
Having access to WP web site recordsdata via WPMUDEV’s Hub is a swift, streamlined enjoy.

3. Navigate to: Information > wp-content > topics > twentytwenty (or no matter theme you’ll be the use of)… and find the unmarried.php or singular.php report.

4. Keep a copy of this report, then rename it. I’m going to name mine: jbtest.php.

Duplicate & rename a php file in WP
Growing and modifying a php report in WordPress.

5. Now we want to transfer this report into the templates subfolder (below twentytwenty).

You’ll word that the recordsdata already populated listed here are preceded through “template–”, so we’ll rename the report once more to check that conference, making mine: template-jbtest.php.

Creating and editing a php file in WordPress.
That is how the folder and recordsdata take a look at this level.

Now that the report is called correctly and in the right kind folder, we want to edit the contents so it’s coded as a template.

6.  Cross into modifying mode (right-click the report, and make a choice Edit textual content), and on the very most sensible of the code, upload the next:


/*
* Template Title: JBTest
* Template Put up Sort: put up, web page
*/
?>

Pasting the template code into the PHP file.

The place the code reads “Template Title Posts: JBTest”, use no matter identify you prefer (instead of JBTest).

Word: Be certain that each and every line of this most sensible degree code is by itself row. (It should show in one line while you paste it.)

7. Exchange the remainder of the report in no matter means you prefer, to make it your personal. Be sure you click on “Save & Shut” after finishing the edit.

Insert test text php file
I added some random “trying out” textual content additional underneath, as a visible validation that the code labored.

Create a New Put up The use of a Template

Let’s create a brand new put up, so we will take a look at out the template we simply made.

1. From the WordPress dashboard, create a New Put up.

2. In the correct facet menu, you will have to see a column referred to as “Put up Attributes”, with the header “Template” underneath it.

3. Click on at the Template dropdown menu to look the various templates to be had. Your new template can be indexed there as you named it, so pass forward and choose it!

New Template type in dropdown menu of Post Editor
Create your put up and put it aside, or just save and preview to get a take a look at it.
Preview of post made with custom template
Preview of a New Put up made with my customized template.

There’s my “take a look at” message. It’s no longer very lovely, however that’s simply mounted through formatting, reminiscent of including padding, converting font kind, taste, colour, and many others. The essential factor is, it certainly did what we would have liked!

Now, let’s take a look at the plugin manner.

Create a Customized Put up Template with a Plugin

In the event you don’t wish to contact any code, you'll be able to decide to move the plugin course. On this instance, we’re going to make use of the Customized Layouts plugin.

Head to the WP plugin repository to get the Custom Layouts plugin.

Custom 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 Upload New Template button.

Custom Layouts plugin, add a template
Customized Layouts plugin, upload a template.

3. This may occasionally open the Template modifying mode, which goes with Gutenberg blocks by way of the left facet of the display.

You'll paintings from the Template or Component tabs, obtainable at the appropriate facet of the display. Be sure you identify your template, and put it aside when entire.

Custom Layouts plugin, Template editing mode.
Customized Layouts plugin, Template modifying mode.

4. You'll save this as a template for any long term posts, or use the shortcode (furthest appropriate facet panel in modifying mode) to show a unmarried example of the template.

In the event you desire, you'll be able to paintings from the Layouts menu, which permits for simple setup of grid kind posts. The entirety you do right here may also be stored as a template for long term use, or through the use of shortcode to show the format.

Custom Layouts plugin, Layout editing mode.
Customized Layouts plugin, Format modifying mode.

5. You'll View, Edit, or Delete Templates or Layouts at any time from the dashboard plugin submenus.

Custom Layouts plugin, saved templates list.
Customized Layouts plugin, stored templates checklist.

Put up-it Notes

There you have got it… two somewhat fast and simple tactics to present person posts a singular taste.

For individuals who in particular revel in DIY, take a look at this in-depth article at the weblog, Creating Custom Content in WordPress: Custom Post Types.

Editor’s Word: This put up has been up to date for accuracy and relevancy.
[Originally Published: November 2011 / Revised: April 2022]

WordPress Developers

[ continue ]