Skip Navigation

[Resolved] Templates for Custom Posts

This thread is resolved. Here is a description of the problem and solution.

Problem:
How can I have Templates as my WordPress Pages have, but in posts or Custom Posts?

Solution:
With WordPress this is only possible by creating Custom Templates that address your Custom posts following the WordPress hierarchy.
https://developer.wordpress.org/files/2014/10/template-hierarchy.png

With Views you can style the CONTENT part of your posts:
https://toolset.com/documentation/user-guides/view-templates/

With layouts on the other end, you can create Templates to use for any Post Type
https://toolset.com/documentation/user-guides/#layouts

You will need to integrate Layouts first with your Theme:
https://toolset.com/documentation/user-guides/layouts-theme-integration

This support ticket is created 8 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 11 replies, has 2 voices.

Last updated by AlexS6170 8 years, 1 month ago.

Assisted by: Beda.

Author
Posts
#419755

Hello,

I've simply added a new post type (projects). I want to make the new project page identically with the normal page (to have exact the same options) botn on the edit project page and on the preview project page. I don't know how (basically keep all the templates from the basic default page)

I've done that to organize stuff and to be able to create custom views for the portfolios.

Many thanks, A
Alex

#419863

I don't understand you.

Do you mean, you want all the Edit options that WordPress provides in the Backend, as well in the Front End when previewing a Post?

This is not possible.

What you can do to partially achieve this goal is create some CRED Forms to edit your Posts, and then display them somewhere on your front-end.
Here you can see how to set up CRED Forms:
https://toolset.com/documentation/user-guides/creating-cred-forms/

Please let me know in case I misunderstood you.

#419876

Well, in short I want to create another tab in wordpress admin menu named portfolio which pages should be exaclty like normal pages, so they should have exactly the same options in the edit page and in the frontend page.

Most of the themes I use have say 3-5 templates, which control what gets displayed or not.
For example, the full-width template might not display the slider, or Page Template 2 might not
display the "ad block" at the top.

Actually I'm trying to put the default theme templates to be awailabe on my custom type (projects).

Thanks

#419880

This is not possible with WordPress Post or Toolset Custom Posts.
It's only possible with Pages.
You can see that when you disable all Plugins and use your theme, navigating to Posts > Edit.
You will not see any Theme's template there.

Page Templates, which is what you refer to, are specific Templates to display Pages.

What you can do is use the Layouts Plugin.
This would let you create Layouts which you can use as Templates even for WordPress native Posts or Types Custom Posts.

Layouts needs to be integrated with your Theme:
https://toolset.com/documentation/user-guides/layouts-theme-integration/

This would allow you to acheive similar outputs.

To give other page properties (such as setting a parent, or menu order) in the Custom Post types, you can activate the Settings for your Post Type in Toolset > Post types > edit > "Sections to display when editing (post type)" and (on the same screen) in the Options tab.
The settings to look for are:
- Page Attributes
- Post Formats
- Pages

#423278

Hi, thanks for the answer.
I saw this post https://toolset.com/forums/topic/choose-from-existing-theme-page-templates/
which is asking for the same thing but I don't pretty understand the solution.
I remember doing something simmilar on an older website and I remember duplicating a .php file and changing the name to apply to the custom type as described in the before mentioned post.

Could you please describe those steps again?

Actually I created the custom post type - projects and created a new project. When I preview it, it shows up as a general post. I want to show up as a general page (or have options to choose between full width, default, and other page templates)

Thanks,
Alex

#423369

Yes, as Caridad elaborates, it is what I mentioned above, that those templates are for pages only.

So what you can do is use Custom Code, and enrich your theme with Templates that follow the Template hierarchy.

A WordPress theme is following the Hierarchy outlined here:
https://developer.wordpress.org/files/2014/10/template-hierarchy.png

So if you want a Custom Template for a given post type, what you do is copy the single.php template and rename it single-your_post_type_slug.php

Then, in that File, you alter the code so to have the look you want.

This is full Custom Code and assistance for it can not be given in Toolset Forums, as it is a WordPress topic, those forums would be the best start place, to begin.

What you can do to avoid Custom Code, is to use Content Templates and style the Content of your Posts, or, you can use Layouts, and create Templates for any Post you need.

DOC for this is here:
https://toolset.com/documentation/user-guides/view-templates/
https://toolset.com/documentation/user-guides/#layouts

#423406

Ok. So there is no way to creat some kind of duplicate of the default pages but names as portfolio and have all the default pages options, templates etc.?

The only way is to create custom types and customize them to look like default pages?

Thanks,
Alex

#423407

For example I tried just to create a simple portfolio post and it shows up as the default posts. I don't know how to remove the sidebar, and the Posted by xx on July 26, 2016 to be like normal pages.

And I haven't added anything on Edit post type page to show these additional things.

Thanks,
Alex

#423408

Pages, and Posts, are not the same in WordPress.

If you want Page Attributes, such as your Templates delivered with the Theme, you need to use Pages.

The only way to customise the template a Post uses, is to use Custom Code, or, as above elaborated, the Layouts Plugin.

This is what makes that Plugin relatively unique, as with very less Code, you can do things you usually only can do with PHP.

So, yes, you either need Layouts, or style the content with Content Templates, or use a Custom Coded Template.

#423410

Ok I understand. I will be using layout plugin but I don't really understand how to integrate it. I read the article you provided https://toolset.com/documentation/user-guides/layouts-theme-integration
but I don't really understand how to do it. FOr example on the 1 step do I need to replace onlt the single.php file with the_ddlayout( 'default-layout' );
Is default-layout somewhere defined?

Thanks

#423412

'default-layout' is not needed.
That will just load a Layout with slug 'default-layout' in case it exists.

You can include the_ddlayout(); (without any call to 'default-layout') and that will replace the Loop with any Layout assigned to it (the post type or single post).

We need to handle this in a new Ticket, in case you need assistance with integration of Layouts.

We will be happy to assist you.

#423803

Thank you, I solved it!

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.