So you’re building a custom WordPress theme and you’re just about finished.
You have our HTML templates created but you want to convert them into WordPress.
You have different page styles and designs, so you’ll need custom page templates for all of the different page layouts.
An easy solution for this is to simply create the page templates in PHP and either write in the content and images in HTML.
But, let’s say you want to be able to edit the content or images from within the WordPress dashboard using their editor or, likely a common case for most WordPress developers: your client wants to be able to edit the page’s content.
Now, the chances of them having experience with editing HTML or using an FTP client are probably pretty slim.
To create an editable page template, your workflow might look a little something like this:
When it comes to adding templates to pages, the process is pretty straightforward.
But adding the same functionality to WordPress Posts seems to be a common question asked in the development community.
One of the greatest things about using WordPress is the ever-growing community willing to help one another.
It seems like there is a plugin for every issue or need developers may have.
While plugins can solve issues you may not be able to solve on your own (and potentially save you a shitload of time), sometimes we want to do stuff on our own.
There is also a handful of other reasons why you want to avoid using a WordPress plugins like security, pagespeed, etc.
When I first started learning WordPress development, I took to Google to find out how to create custom post templates, but finding an answer was a little more difficult than I expected.
Luckily, the solution is actually very simple.
<textarea readonly="readonly" style="color: #03fc96; height: 350px; background: transparent;">/*
Template Name: Full-Width Template
Template Post Type: post, page, product
*/
get_header();
?>
/*---Add your content here---*/
<!--?php get_footer(); ?-->
</textarea>
And that’s it!
Now you can create a new post and on then you’ll see the “Post Attributes” box with a dropdown arrow to select your custom post template.
You shouldn’t have to add anything to your functions.php file.
Simply having a php file with “Template Name: Full-Width Template Template Post Type: post, page, product” in the meta info will do the trick.
Check out more of our WordPress tips, tutorials, and resources.
Be a lot cooler if ya did
We send nothing but the good shit. Once a week. That’s it.
Stay up-to-date with all of the design and creative news, resources, and inspiration by signing up for the CreativesFeed newsletter!