Skip Navigation

[Closed] 2 post types in one view, different column layout for each

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

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 2 years, 10 months ago.

Author
Posts
#2306807

I have a view that displays two different custom post types, so one loop. Is it possible to show each CPT with a different layout? Specifically, I want an instance of one post type to be full page width (1 column) and the other to show two posts per page width (2 columns).

So like this:

CPT 1------------
CPT2---CPT2---
CPT 1------------
CPT 1------------
CPT2---CPT2---

etc.

#2306843

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi John

What you show above pre-supposes that the ordering will always be kind, with two posts of type CPT2 always appearing in sequence so that they may be shown in adjacent columns, I'm not sure now likely that is.

In any case, I would approach this by applying classes to each iteration of the loop output that will determine the width they occupy, and conditionally apply those using conditional shortcodes that test the post type.

So that if the post type is CPT1, add the class width-100, and if the post type is CPT2, add the class width-50, something like that.

<div class="[wpv-conditional if="( '[wpv-post-type]' eq 'CPT1' )"]width-100[/wpv-conditional][wpv-conditional if="( '[wpv-post-type]' eq 'CPT2' )"]width-50[/wpv-conditional]">
// content
</div>

The topic ‘[Closed] 2 post types in one view, different column layout for each’ is closed to new replies.