Single Custom Post Type Template

Posted onby admin

If you want a particular post or post type to stand out from the rest of your content, you may want to consider creating a custom single-post template. This template will only be applied to the post(s) you assign it to, meaning it can have an entirely different layout than your standard posts. The single post template used when a visitor requests a single post from a custom post type. For example, single-acmeproduct.php would be used for displaying single posts from a custom post type named acmeproduct. From WordPress version 4.7 you can now assign custom page templates to other post types along with page. To achieve this in addition to the Template Name file header, the post types supported by a template can be specified using Template Post Type: as following.

Contents

WCK Swift Templates makes it easy to create a Custom Post Type Single Template that will display the attached Custom Fields and Taxonomies.

You can achieve this without writing any PHP code, directly from the WordPress admin interface. The steps below will guide you on how to create a Custom Post Type Single Template using WCK Swift Templates.

Building the Custom Post Type, Custom Fields and Taxonomy

With WCK Swift Templates creating a Custom Post Type Single Template is done together with the creation of the Custom Post Type Archive Template, so the same steps apply.

For this tutorial we’ll follow the same example of using a Custom Post Type called Movies, created using WCK Custom Post Type Creator.

As you noticed, the “Movies” Custom Post Type has attached a Single Custom Meta Box called “Movie Information” with the following Custom Fields: Poster, Release Date, Director.

Below it there is a Repeater Custom Meta Box containing “Movie Actors” with the following Custom Fields: Name, Role, Picture.

The Custom Post Type Movies has also a Custom Taxonomy attached called “Genres” created using WCK Custom Taxonomy Creator to classify each movie easily.

Creating the Custom Post Type Single Template using Swift Templates

We want the “Movie” Custom Post Type Single Template to display all the Custom Fields and Custom Taxonomy information. Usually the default WordPress Custom Post Type Single Template only displays the Post Title and Content.

WCK Swift Templates offers an UI for building your own Custom Post Type Single Template with all the attached Custom Fields and Taxonomies.

We’ll create a new Swift Template and name it “Movie List”. Then we need to select a Custom Post Type that our Single (and Archive) Templates will be based on. From the dropdown select “Movies”.

Then we’ll select a Query Argument. You have a lot of options here (as seen below) starting from Posts per Page, Order, Order By etc. to Tag or Category ID.

We’ll choose Posts Per Page and use the Default Value of 10.

IMPORTANT: After this step make sure to “Publish” your Swift Template so it can generate all the variables needed at the next step.

Moving forward we’ll get to the Swift Template tab were we can start building the Archive and Single Template. In the right side you will see a list of all the available variables for the selected Custom Post Type “Movies”.

For the “Movies” Custom Post Type Single Template we want to display the following information:

  1. Title
  2. Description
  3. Genre
  4. Movie Information
  5. All Movie Actors information

We can start building the Custom Post Type Single Template by selecting the variables we need from the right side and adding them to the left side editor.

Note: To properly display the WYSIWYG Editor Field used in the Swift Template, add the variable with 3 curly braces (3 mustaches): {{{ custom_field }}}

And we can also add a little bit of HTML for a basic layout.

Make sure to mark the checkbox below the Single Template Editor to use it on all posts for the selected Custom Post Type.

Then “Update” the newly created Swift Template and you’re all set.

Now if you have a look at the Movie Single Page it will display all the attached Custom Fields and Taxonomy information.

Feel free to move forward and style your new Movie Single Page in any way you desire.

This short tutorial will show you the way of creating a Custom Post Type Archive and Single Page template with the help of JetEngine and JetThemeCore plugins.

Managing your Custom Post Types with JetEngine plugin is really handy and easy. However, to show the resulting grid you will need an Archive and Single pages. WordPress Posts have those by default but for the Custom Post Type, you will have to create them manually. From this tutorial, you will learn how to create Archive and Single Pages templates for CPT.

Note! You need to have JetThemeCore or Elementor Pro to be downloaded in order to perform steps described in this tutorial.

How to create an Archive Page?

1 Step— Add new Archive Page

Let’s assume that you have already created a Custom Post Type and a Listing Template for it.

Go to Crocoblock > Theme Builder. Here you can see the Theme Parts screen with lots of tabs. Open Archive tab.

Wordpress custom post type template

Click the “Add New” button to create a new archive. Select the type of template as Archive Page and give it a name. Then, click the “Create a Template” button.

2 Step— Define the Archive Page Elementor settings

Custom

Now you can see an empty page in the Elementor page builder. Navigate to the gear icon at the bottom-left corner of the Elementor panel and click it to open the page settings.

Unfold the Conditions menu block and in the General drop-down menu select the “Archive” option.

In the Archive drop-down list select the Post Type Archives option because we are creating an Archive Page for the Custom Post Type. However, you can choose whatever option you need. In the Post Type drop-down, we choose the created post type option.

Afterward, open the Preview block, and in the Post Type dropdown choose the CPT you created.

Now click the “Publish” button in order to save the changes and reload the page.

Now, add the Listing Grid widget, customize it, and create the layout and design that will suit your taste.

Single Custom Post Type TemplateSingle Custom Post Type Template

How to create a Single Page?

1 Step— Add the new Single Page

Go to WordPress Dashboard and openCrocoblock > Theme Builder, the Theme Parts window will appear, so find the Single tab and click on it.

Hit the “Add New” button, name the page and tap the “Create Template” button.

2 Step— Deal with the Elementor settings

Find the gear icon at the bottom-left corner of the Elementor panel and click it. Open the Condition menu block and in the General filed choose the “Singular” option. After that in the Singular drop-down menu pick the “Post Type” option and in the Post Type field select the Custom Post Type you have created.

Afterward, unfold the Preview section and in the Post Type drop-down list choose the created CPT.

After all is set, use the Dynamic Widgets to showcase the needed info. In simple words, when the user is clicking on the exact post in the Listing Grid they will see the Single Post that we have created.

Single Custom Post Type Template Free

That is all for the Archive and Single Pages creation. You now know how to do it with the help of JetEngine and JetThemeCore plugins.

Wordpress Custom Post Type Template

Boost your site with Crocoblock!

Wordpress Custom Post Type Single Template

Take a look at more than 100 unique widgets and find the right ones.