Skip Navigation

[Resolved] Custom layout for WP archive pages for custom post type

This support ticket is created 6 years, 5 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 9 replies, has 2 voices.

Last updated by Shane 6 years, 4 months ago.

Assisted by: Shane.

Author
Posts
#1076443
Screen Shot 2018-08-07 at 11.53.19 AM.png
Screen Shot 2018-08-07 at 11.53.25 AM.png
Screen Shot 2018-08-07 at 12.03.10 PM.png

I've created a view in Toolset that loops through a custom post type I created. I added the shortcode for this view to a page I created and all is working fine. However, in order for the links for custom taxonomy to work properly it appears I must use the default archive pages. For example, I created a taxonomy called "Specialties" and when this is listed for each item the links take the user to an archive page /specialty/specialty-name. This page can be found: hidden link

I'd prefer to be able to change the layout of these archive pages much like I did when creating the new page and adding my shortcode. What is the best way to accomplish this? The archive pages have a default background and different HTML for the containers/structure, and these are not editable like other pages: hidden link

What's the best way to use the desired view created in Toolset but also to be able to style the page/layout of the archive pages?

Similarly, is there a way to edit the individual custom post pages to include custom fields or other custom content such as a form (besides just the main description of the post which appears to be default)? example: hidden link

Thanks,
Austin

#1076490

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ryan,

Thank you for contacting our support forum.

Not sure from your post if you've already tried this but you can create custom archive templates using our views plugin by going to the Archives option.

Secondly for the individual post templates you can create content templates and assign them to the individual posts. In the content template you can add the shortcode for the custom fields so when viewed on the frontend the custom fields will appear as well.

Thanks,
Shane

#1076520
Screen Shot 2018-08-07 at 1.41.25 PM.png

Thanks Shane. I created a content template for single posts. What path do I use to access this single post view based on the content template? Or do I need to assign it/add it somewhere else in order to activate it? See screenshot, does this mean it is being used on my "Ancillary Listings" custom posts? If so, where does it exist?

For my main question, the problem is not with the search/pagination and listings being displayed, but more that I have a custom archive listings page hidden link where I CAN manage the layout but where the taxonomy links take users to this page hidden link where I have less control over the layout.

I'd like to make the experience consistent so that the (1) archives listings (2) the taxonomy archive pages and (3) the single post archive page has some consistency. I guess my question is which do I change and how can I manage the layout for the category archive and single pages, if this is what I must do?

#1076539

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ryan,

If you go to each of your listing items you can edit them and then assign the content template to the posts.

On each of your post there should be a content template section when you edit them. This is where you can assign the created template to the post.

For the archive, i see you want these 2 pages.

hidden link

and

hidden link

To look similar correct?

Please let me know.
Thanks,
Shane

#1076550

Okay, I see. So you basically can assign a specific "content template" to an indvidual post. My next question is: can 1 and only 1 content template be assigned to each post? In other words, if I want a "main view" at path /ancillary-listings/main-view/post-slug and an "alternative view" at /ancillary-listings/alternative-view/post-slug for the same single post, is this possible?

If not, it looks like I will need to create 2 custom post types, name them each something different and include distinct fields for each, and then create a different content template for each. Does this sound like the right solution to you based on what I'm asking for?

Also, is there a way to set the default content template for a custom post type, such that every time a new custom post is created it is assigned the same content template (versus individually going into each post and assigning the template each time as you described in your response)?

On your last question above, yes that's correct.

hidden link

and

hidden link

I'd like for them to be consistent but since the archives can't be edited like normal pages, I'm getting this type of conflict. The custom page I made for the listings view doesn't do me much good if the taxonomy archive links go to another page with different layout, for example.

Thanks

#1076554

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ryan,

Yes you can. You can assign different content template to each post in that CPT.

Yes you can set a default template. At the bottom of the edit content template screen there is a usage option.

From here you can set the default CPT that when a post is created it will get that content template assigned automatically.

Thanks,
Shane

#1076564
Screen Shot 2018-08-07 at 4.24.32 PM.png
Screen Shot 2018-08-07 at 1.41.25 PM.png

Hi Shane,

I think we're losing a few specifics in the communication but this is helping my understanding, so thank you. As I understand from your response, there is only one "single post" template I can create for each post. I have the ability to edit the layout with content template, but there is no ability to create 2 single post views and assign a different content template to each.

1 post = 1 single post template doesn't help with this need. However, it is useful to know this is how the relationship works. I'd like to ideally have 1 post = 2 single post templates each with separate path to access.

On your comment about "usage option" in the content template, help me understand what I missed. In the screenshot you can see the usage is set to my custom post type "Ancillary Listings" (this is my custom post type). However, the single post for my custom posts were still just showing the body of the post, not the content template.

Second, when I went in and manually set the content template to the one I just created, I get duplicate information added after the content template. I also couldn't get the post body to show up. See 2nd screenshot. Sorry this still isn't quite working very well as a solution for me yet. Does my code look right for the content template? Can you explain the duplicate fields?

#1077460

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ryan,

Perhaps its cause we are addressing multiple questions at the same time. So what we can try doing is to address the questions one at a time.

Here goes.

1. From what I can see here you want 1 post to be able to have 2 different template right ? Will the template that is used based on some custom field value ?

2. You're saying when you set the usage for your content template to your CPT, your new posts are not created using this content template?

3. The duplication of the fields i'm not sure why this is happening as is seems the template is being loaded twice somehow.

Would you mind allowing me to have access to the site so that I can have a look at issue #2 and #3?

Thanks,
Shane

#1079832

Hi Shane,

No need to worry about 2 and 3. Let's focus on 1. My problem is best explained by clicking the taxonomy links on this page found next to "Specialties" or "Categories": hidden link

That main archive/listing page was created with Toolset. However the taxonomy archives are not. I would like to be able to modify the taxonomy archive pages OR create a separate archive page and redirect the taxonomy links to those pages. If this is too difficult, I'll simply remove the anchor links from the taxonomy sections of the main archive listing page page linked above.

If you have a straightforward suggestion, I'll give it a shot. Else I'll just remove the anchor links and this ticket can be closed.

Thanks

#1081495

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ryan,

I would like to have a look at the site.

There shouldn't be any reason why you're not able to create a custom taxonomy archive.

The private fields will be enabled for your next response.

Thanks,
Shane