A Content Template lets you control the content part of WordPress posts, pages, and custom post types. Normally, these pages include a header, sidebar(s), menu, title and footer. Of all these, the Content Template is responsible for the content part.
This image illustrates it:
The Content Template will fill the content part in this picture. With a Content Template, you can display static text, HTML and any field that this content type includes. The end result can be something like this:
Adding Static Text, HTML, and Fields
When you create a new Content Template, you’re going to see a page like this:
You can organize the output of your content template into columns, by using the Grid button.
Here is the Content Template meta HTML that produces the showcase example above:
<div class="info"> [types field="url" title="Visit site" class="visit-site"] <div class="section">Rating</div> <p>How do you like this site. Rate it based on their design, originality and overall appeal.</p> [ratings] <div class="section">Category</div> <p>[wpv-post-taxonomy type='showcase-category' separator=', ']</p> </div> [types field="image" size="full" align="none"] <div class="post-body"> [wpv-post-body view_template='None'] </div>
The code starts with
<div class="info">. This will wrap the button to visit site and stars rating.
Then, the Content Template displays the image field and finally, the post’s body, inside a div called post-body.
You don’t need to memorize these different shortcodes in order to insert them. Click on Field and Views to insert all the fields that are available for the content type that uses this Content Template:
The different fields are arranged under sections, to make it easier for you to find them. You’ll see:
- Basic – this section always appears. It includes the standard fields that exist in any WordPress content, like body, title and URL.
- Taxonomy – if this content uses taxonomy, it will appear as well.
- Content Templates – you can insert other Content Templates
- Custom fields – you’ll see a section for each content type. Under it will appear the different custom fields that can appear for that content.
- Views – if you’ve created Views, you’ll see them under the Views section.
The dialog from Fields and Views button includes a search box. This might be your fastest route to locating fields. As you type in the search, the results will update to filter only the matching fields.
Just after the Content Template editor, there is a Usage section. In this section, you can choose which elements will use this template. You can select between the post types (posts, pages, custom posts types), post archives and taxonomies archives.
On the bottom part of the Content Template edit page, you’ll see an Output mode section. There, you can control if this Content Template uses the normal WordPress output processing – Auto-insert paragraphs, or raw output – Manual paragraphs.
By default, WordPress adds paragraphs and line breaks automatically. For example, if you write:
This is line #1 This is line #2
You’ll get this HTML output:
<p>This is line #1</p> <p>This is line #2</p>
Most of the times, these automatic paragraph and line-breaks are convenient and you’ll want to use this mode. However, sometimes they make your HTML output difficult to control. For example, if you’re creating an HTML form, you don’t want WordPress to insert
<p> elements around
In this case, use the Manual paragraphs option. Then, Views disables the normal WordPress processing and outputs only the HTML markup that you’ve written, without any further processing.