Using a template for custom post types

I am creating a custom post type to allow me to use the spirit theme to create property websites.

Lets assume we create a custom post type called "properties"

Within properties there are a number of custom fields such as price, images, location, description etc everything youd expect from a property detail page.

Firstly, I cannot seem to apply a theme template to the custom post type.

Secondly, if I edit the page in upfront and save, it asks me if I wish to apply this layout to all posts of this kind, I select yes.

My assumption would be that if a new property is added, when you view the page it would have the same layout as previously designed, but this seems to not be the case.

What I need to acheive is this...

Create a custom post type, and have some kind of template applied to it.

Create one test property, go to upfront screen and edit the layout for that property, with shortcodes and plugins etc.

We then use an importer to create lots more properties automatically each day, so these are not manually created, but I want each new property to have the same layout as the first dummy one created, I cannot seem to achieve this.

I also have issues with your google maps plugin not showing the map location based on custom fields in the properties custom type.

Hope that makes sense.

  • Predrag Dubajic

    Hey @Jason,

    Thanks for your questions.

    We are aware of the issue with the layout not saving for all posts of the same type, our developers are working on fix for this.

    As for adding extra fields, it might be best to go with shortcodes, you can use them both in post content and text element.

    I also have issues with your google maps plugin not showing the map location based on custom fields in the properties custom type.

    Could you elaborate this a bit more or allow support access so we can have a look at your settings?
    To enable support access you can follow this guide here:
    https://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/
    You might want to open new thread regarding this issue so it doesn't get confusing answering multiple issues in same thread.

    Best regards,
    Predrag

  • Jason

    Hi.

    I have enabled access for the maps problem, I will create a new ticket for that, but thats not so important right now as the below issue.

    However for the custom post types issue, im not sure if I may be defining the problem clearly as im not sure anyone so far has understood what im trying to do.

    I think I either need to share my screen to demonstrate, but ill do my best to re explain.

    I have used the "pods" plugin to create a new custom post type in admin called "properties" this allows me to add a new property to the website. In the same way as I add a new web page or post. The properties admin section will have extra fields such as price, location etc

    Now the first problem is this.

    I want to create a master blank template for those properties, every property will end up with the same layout. But to start with I seem to get defaulted to a template design that isnt anything like my other pages, and I do not know how to stop that happening. So maybe somewhere i have to duplicate a template in the theme structure to be used with my custom post type?

    Then once that initial page is layed out ALL new properties added to the site should be layed out in the same design.

    Now we don't add properties manually, we use an importer plugin to import multiple properties into the custom post type. Therefore each new imported property should take on the same design as each other.

    We currently acheive this using pre built themes for the job, but purchased your solution as we had been lead to believe (David,
    Pre-sales, Accounts & Billing) what we wanted to do is completely possible.
    an example property page layout for an existing site using a pre built theme is here

    http://www.propertywebtools.co.uk/harrisions/property/2-bedroom-flat-to-rent-in-orchard-court-new-milton/

    so the page is layed out according to the template file I presume, and every new property imported into that site has the page layed out identically.

    This is what I am trying to achieve with upfront.

    Now for the elements such as title, maps, features etc, I can do that using shortcodes and placing those shortcodes where I want the data to be displayed. So from what I see my only problem is getting that initial design done for the custom post type, making that show, and save in upfront, then replicating that design across all new posts added t the custom post type.

  • Sandra

    Hi there,
    I'm also interested in creating a custom post type post template and post list template - I stumbled upon this page (yes, I'm using Upfront with the Spirit theme as well).

    I figured out how to add a custom post type to a page and can (mostly) style the generic post elements (can't figure out how to change the fonts and colors of any of the elements' text, but that's a different problem...)

    Here's what I'm doing: I drag and drop the 'Post' element onto a page, and set 'Query Settings' to:
    What to Display: 'Single post ' or 'Post list'
    How to Display Post(s): select 'Post by taxonomy'

    1. I want to create a create a template for the actual CPT post.
    a) I'm not sure how to make sure the full content is displayed (that option is missing in Query Settings for Single Post)
    b) I have photos embedded in the post content - they do not appear.
    c) user can still click on the post title and is directed to the actual post page which is not the way I want it displayed (ideally, I'd like to templatize that page too)
    d) I've added the Custom Press Taxonomy and Custom Fields shortcodes as text elements to the page but get nothing
    e) Once I get the shortcodes embedded and displaying correctly, can I still style them the same way I style a text element in Upfront?

    2. I want to create template for the CPT post list.
    a) I seem to have to choose 'Freshest From' and then 'By Term' and 'By Term'. So far it's ok (I don't have many posts), but not sure how the sorting will go when I do have multiple posts in categories/taxonomies that are sorted ahead of something else that has a more recent publish date.

    Any help is appreciated.

  • Predrag Dubajic

    Hi @Sandra,

    Thanks for posting in this thread, however it might be best if you open your own, even if the issues seem closely related. That way it will remain independent of this one and ensure it doesn't confuse issues here if this thread needs reopening again by the author.

    It also means the member who started this thread or anyone following it isn't inundated with post notifications each time we respond to each other. A lengthy thread could annoy the original poster.
    This also allows us to better track and answer your questions to ensure we don't miss any for you.

    You can start a new thread here:
    https://premium.wpmudev.org/forums/#question

    Best regards,
    Predrag

  • Morgan

    Hi Predrag,
    While I wait for a solution to this problem, I am searching for other ideas on my own. I sent in a support request a couple days ago. Usually responses are quicker. I don't usually approach others, but this description sounded eerily similar.

    Even though there may have been many updates to Upfront since the original post, the problem I've encountered sounds much the same. It may have different causes but it hasn't improved from the user's perspective. I'm doing what Sandra described. I have a custom post type. I need to create a detail page and a list/archive page for it. Upfront doesn't save my changes to these pages, nor does it provide any helpful errors in the UI for me to figure out what's wrong.

    I cannot progress with my current project until Upfront behaves as expected or a support hero can provide me alternatives. While I'd like to do this in Upfront, 'wait for the next update' is not a viable solution. How feasible is it to do handcrafted templates for the custom post type pages that Upfront can't seem to handle?

    I guess I will keep searching for solutions to try out until I someone at WPMU can send me one. I'm not sure what else I can do and I'll likely lose this contract if I can't make progress.

    Regards,
    Morgan

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.