Being one of the most renowned website creation platforms, WordPress needs no introduction. Within minutes, we can create our website on WordPress without any hassle. Since there are tons of themes and templates, making the website stand out is easier.
We can even create custom single post templates on WordPress. It refers to a unique template for every post. For creating such templates, we use a wide array of layouts and styles. Thankfully, there are various methods to do so. We can pick our preferred option and integrate customization in no time.
If you have no clue about creating these custom templates, read below:
Benefits of Creating Custom Single Post Template
When we have an entirely different layout of one post, chances of user engagement are higher. Since the post looks distinctive, viewers like to have a look at it. People who deal in digital marketing services can make the most of this feature. They can enhance the engagement of most trending posts and increase Google ranking.
Is It Mandatory to Have Coding Knowledge?
Though you can easily create these custom single posts through coding, it is not mandatory. However, if you are opting for the coding method, you can put codes in a blank PHP file. Since every other person is not a coding expert, there are other methods too.
They include:
The Beaver Builder
This method is the easiest way of creating custom templates. Without using any coding, it lets you uniquely design the templates. Here are the steps for it:
- Download and install the Beaver Builder.
- Go to the settings and change enter the given key in the license tab. Go to the site and check this information under your record.
- Again, go to the settings and click on the Post Types button. From here, change the setting to Beaver Builder Page.
- Search for the option that is closest to your choice. Also, do not forget to save the changes.
This is the basic setting, after which you can proceed with the custom-made template. Now, you need to go on another post, launch the plugin, and you are all set to create your template.
Theme Settings
You can also change the layout if your theme supports this feature. Many latest themes provide this facility, and you can do it through the Post Edit option. While editing a single post, you may find the option of changing the sidebars, menus, title, headers, etc. Thus, you can customize it easily.
Additionally, you can also use the ready-made templates offered by some well-known themes. But you need to see if they are available for the single posts. Go to the Post Attribute tab to find this option.
Block Editor
If you are not much concerned about the depth of customization and only looking to save your single post settings, Block Editor is the right choice. Though it has critics related to customization, it is ideal for those who want to reuse their single post blocks.
In a basic version of the Block Editor, you will find a Group block, which is reusable. Here you can save the post layout along with multiple blocks into a single block. Afterward, you can use this block for other posts too.
Here is how you can do it:
- Create a new post, go to the content bar, and add a group block.
- You will see all the block options. Start adding one by one to create a custom post template.
- Once you successfully create your desired layout, go to the group block option, select the dotted menu option, and click on the Reusable Block.
- Now, type a name for the reusable block and save it.
- You can now use the reusable block for existing as well as new posts.
- You just need to go to the Post Edit option then click on Add New Block. From here, select your reusable block.
Remember, in this option; you can change the custom layouts but not the way how your theme deals with the single posts.
Category Based Selection of Custom Single Post
If you want to select a customized template based on category, doing it is possible. It means all posts from the health category will have the same template but differ from the beauty category.
For this, add the following code to your site-specific plugin or function.php file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | /* * Define a constant path to our single template folder */ define(SINGLE_PATH, TEMPLATEPATH . ‘/single’);
/** * Filter the single_template with our custom function */ add_filter(‘single_template’, ‘my_single_template’);
/** * Single template function which will choose our template */ function my_single_template($single) { global $wp_query, $post;
/** * Checks for the single template by category * Check by category slug and ID */ foreach((array)get_the_category() as $cat) :
if(file_exists(SINGLE_PATH . ‘/single-cat-‘ . $cat->slug . ‘.php’)) return SINGLE_PATH . ‘/single-cat-‘ . $cat->slug . ‘.php’;
elseif(file_exists(SINGLE_PATH . ‘/single-cat-‘ . $cat->term_id . ‘.php’)) return SINGLE_PATH . ‘/single-cat-‘ . $cat->term_id . ‘.php’;
endforeach; } |
After checking, the Word Press looks for the file of the single post template. You will then add the template files.
Here are the other steps:
– Go to /wp-content/themes/your-theme-folder/ through WordPress hosting.
– Create a new single folder under the current theme folder.
– Now, create a new file inside the folder.
– Here, you will see single-cat-{category-slug}. Now add your category in place of the category slug. Like for the travel category, you can write single-cat- travel-tips.php.
– Now, these files will appear empty. You can take the contents of your single.php files and edit them.
Final Words
In short, there are multiple ways to get a custom single post option. You need to select the one that suits you better. You can even do it manually if you have some coding skills. However, lots of plugins are also available to make this process easy.
So, make your posts stand out with a little effort. Try out the above methods and post your reviews in the comment section. If you’re a web design freelancer, go ahead and use Prospero proposal templates to seal more deals with clients.
Author Bio:
Shoaib provides ghostwriting and copywriting services. His educational background in the technical field and business studies helps him in tackling topics ranging from career and business productivity to web development and digital marketing. He occasionally writes articles for Dynamologic Solutions.