Content Templates let you create page templates from the WordPress admin, without any coding.
You edit Content Templates as regular HTML and insert custom fields, standard fields and taxonomy, using the View menu.
- Code-free website development
- Design without leaving the WordPress admin
- Easy design with syntax highlighting
Content Templates are one of the powerful features in Views plugin.
Already purchased? Skip to tutorial
Content Template Highlights
When you use Content Templates, you’ll be able to create any page template, including any field, right from within WordPress. It’s not going to be just easier and faster, but also a lot more flexible than hard-coded PHP templates.
- Select the Post type for your Single page – Goto Content templates, select Usage for single page and choose one of your post types.
- Insert fields from Views GUI – Click on the V icon, from either Visual or HTML modes and choose the field to insert.
- Set field attributes from Views GUI – In addition to inserting fields, Views let you choose their properties. For example, set size for images, anchor text for links and values to checkboxes.
- Edit Content Templates in Visual or RAW modes – ever tried to create valid HTML with WordPress? RAW mode lets you bypass all the line breaks and paragraph injections. You’ll be able to build forms and any other HTML, without any WordPress ‘magic’.
- Use Content Templates in Views too – Content Templates work like ‘subroutines’ for your site’s layout. You can use the in Views, to achieve complex visual display, using simple code.
Using Content Templates
Step 1 – Create a new Content Template
Let’s create a simple Content Template for a real estate website. We’ll add a Single page template for our Properties custom post type.
Navigate to Content Templates and arrange by Usage for single page. Select your Post type, in this case Properties, and click to Add a new Content Template.
Step 2 – Add Fields to the template
To add content fields, click on the V icon to open the Shortcode Inserter. You’ll see a list of all the available fields, and you can Goto any of your Custom field groups. Click on any field to insert the shortcode into the template. You can use the Search feature to instantly locate fields by their names.
Step 3 – Design the template using HTML tags
Content Templates work like ordinary WordPress content. Use HTML tags set control the layout of the template. You can add classes and styles to any Views shortcodes.
The editor includes a convenient syntax highlighter, which lets you easily craft your HTML. It’s very similar to writing ordinary WordPress content, however you’re actually creating page templates.
In Content Template Settings, you can override WordPress’ default and ensure that no paragraphs, line breaks or other unwanted markup is inserted into your template. You have full control over the final ouput.
Step 4 – Style the Template
Content Templates make it easy for you to separate between layout and styling.
A CSS editing section, complete with syntax highlighting will let you enter the CSS for this template.
You don’t need to worry about loading that CSS or adding it to the theme. Views adds it automatically to the output of any content that uses that Content Template.
Step 5 – Use the Content Template for your post
We set Post type for this template when we created it.
From the Content template settings you can choose the Single post where this Content will be displayed.
If the Post type you apply the Content template to, already contains post data, you’ll get a warning when you Save the template.
Click on the warning icon and Apply your new Single post template to your existing posts.
Step 6 -See the Content Template in Action
And that’s it!!
Straight from the Views GUI, you can create fully functional Single post templates and style them exactly how you want, without a line of PHP or messing around with template folders.