Creating templates to display members-only content in WordPress
Your site might have content reserved only for members. In this case, you need to display some teaser content to the visitors and whole content to the logged-in users. Toolset lets you design both of these templates and set which one to display for different types of users.
Here’s an example of a membership site that offers video tutorials only to members.
Logged-in members seefull content
Visitors seeonly partial, teaser content
Follow these steps
To create two templates, one for site members and one for visitors, you’ll need to install the Toolset Access plugin (in addition to Toolset Types and Toolset Blocks)
Here is an outline of what you need to do:
Create two templates – a template for members with the full content and a template for visitors with teaser content
Use Toolset Access to set the template with a teaser to be displayed to visitors
Design the content of both templates
Let’s go through these steps one by one.
Create the templates for logged-in users and for visitors
Go to Toolset → Dashboard and click the Create Content Template button in the row of the post type you want to design a template for.
Go to the Toolset → Content Templates page and click the Add New button at the top.
Give a clear name to this template, something like “Teaser template for visitors”.
Don’t assign this template to any content and click to create it.
You can leave both templates mostly empty. We’ll get back to designing them in a minute.
Display the teaser template only to visitors
Now, let’s change the access settings so that visitors see only the teaser template when they visit our posts.
Go to Toolset → Access Control. All the post types in your site are listed here.
Click to expand the post type with your premium content. A table appears listing all user roles in your site and their permissions for this post type.
Under the Guest row, deselect the checkbox in the Read column. This means that visitors who are not logged in cannot view the default template for this content type.
Click the pen icon that appeared next to the checkbox you deselected. A pop-up dialog appears with options to select what to display for users with no read permission.
In the first section, select the Show Content Template option. In the dropdown menu, select the teaser template you created.
In the second section, select the option to choose a different WordPress archive. In the dropdown menu, select the archive of your preference. This works the same as with templates. In our example, we display the same archive to all users. If needed, you could design a special “teaser archive”, just like for the templates.
Designing the templates
Now that we have two templates, it’s time to design them. The template for members will include the full content that you want site members to see.
You can access both your templates from the Toolset → Content Templates page.
Edit them and use the WordPress Block Editor to design your template.
Choose blocks from the Toolset section for any part of the template that displays fields (not static elements). For example, use the Toolset Heading block for any heading that will display a field.
Enable Dynamic Sources for blocks that should display fields of the post that the template displays.
Template Design Tips
Use the View with dropdown menu at the top of the editor to preview your template with any post of your choice.
Use the screen-size selector either at the top of the editor or next to different fields to design the template for different screen sizes.
Use the View block to display lists of related posts or repeating field groups.
Theme defines the basic layout of single-post pages on the site. This includes options like the width of the page, displaying of sidebar and the page title, and more.
Using one of the themes integrated with Toolset allows you to control the layout of the single-post template. You can set different layout options for different templates.
If your theme is integrated with Toolset use the following steps to change the layout options:
In the right sidebar, click the Document tab.
Expand the Toolset settings for… section (the last part will be the name of the active theme).
Tweak theme options as needed.
Please note that different themes provide different options.
If your theme is not integrated with Toolset, you might try changing the layout options from the Appearance → Customize page, or from the theme’s own settings page.
Displaying a YouTube Video Coming from a Custom Field
Toolset allows you to easily display YouTube videos whose URL comes from a custom field. Additional advantage of using the Toolset YouTube block is that it offers an array of video settings options like the width, aspect ratio, start/end time, autoplay, and more.
Use the following steps:
Edit your template and insert the Toolset YouTube block.
Click Yes to use a Dynamic Source.
Use the dropdowns to select the custom field that holds the YouTube URL information.
In the right sidebar, use the Video Settings section to set custom options for displaying the YouTube videos.