Skip Navigation

[Resolved] News archive with two columns then three columns with filter

This support ticket is created 6 years, 11 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 3 replies, has 2 voices.

Last updated by Nigel 6 years, 10 months ago.

Assisted by: Nigel.

Author
Posts
#608428

Can you help with a design layout I'm stuck with please?

It's a news archive, set up as a CPT. The design has a drop down filter for type of news then two larger news items taking up two columns, then beneath this, nine items in rows of three. (three columns). Then pagination.

filter
2 large items
3 items
3 items
3 items
pagination

I've set the main three column news archive as an archive and the two larger items as a view "News archive top view (two items in two columns)", which works, however the filter only affects the main 9 item block plus I can't offset (or skip) the main loop by 2 to avoid duplicate content

WIthin "Filter and Loop Output Integration Editor " I have:
[wpv-post-body view_template="Content template for News header"]
<div class="container news-drop-down">[wpv-filter-meta-html]</div>
[wpv-view name="news-archive-top-view-two-items-in-two-columns"]
[wpv-layout-meta-html]

Am I doing this wrong? Should I have two views and a filter? Any help would be appreciated, thanks!

#608521

Nigel
Supporter

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

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

Hi John

There is no easy way to do this.

For the pagination and filters to work, the results must all be generated by the same query.

You need a CSS solution to change how you display the first two elements.

That in principle shouldn't be too difficult using selectors such as :nth-child or :nth-of-type.

However, Toolset uses the Bootstrap grid system, which splits content into rows.

Your Loop Output section for the archive presumably looks something like this to achieve 3 columns:

	<wpv-loop wrap="3" pad="true">
		[wpv-item index=1]
		<div class="row ">
			<div class="col-sm-4">[wpv-post-body view_template="Loop item in Things archive"]</div>
		[wpv-item index=other]
			<div class="col-sm-4">[wpv-post-body view_template="Loop item in Things archive"]</div>
		[wpv-item index=3]
			<div class="col-sm-4">[wpv-post-body view_template="Loop item in Things archive"]</div>
		</div>
		[wpv-item index=pad]
			<div class="col-sm-4"></div>
		[wpv-item index=pad-last]
			<div class="col-sm-4"></div>
		</div>
	</wpv-loop>

Which generates markup something like this:

<div class="row ">
	<div class="col-sm-4">...content...</div>
	<div class="col-sm-4">...content...</div>
	<div class="col-sm-4">...content...</div>
</div>
<div class="row ">
	<div class="col-sm-4">...content...</div>
	<div class="col-sm-4">...content...</div>
	<div class="col-sm-4">...content...</div>
</div>
<div class="row ">
	<div class="col-sm-4">...content...</div>
	<div class="col-sm-4">...content...</div>
	<div class="col-sm-4">...content...</div>
</div>
<div class="row ">
	<div class="col-sm-4">...content...</div>
	<div class="col-sm-4">...content...</div>
	<div class="col-sm-4">...content...</div>
</div>

If we use CSS to make the first two items of the first row take up 50% available width each, where should the third item in that row go?

Meaning, we can't use a row based layout system such as the Toolset grid.

Instead your loop output should be simplified to not impose any formatting itself, e.g.

	<div class="archive-container">
	<wpv-loop>
		<div class="archive-item">[wpv-post-body view_template="Loop item in Things archive"]</div>
	</wpv-loop>
	</div>

So you'll have a single container div for all of the results, and a wrapper div for each iteration of the archive loop.

You'll need to add your own CSS rules to turn this into a 3 column grid.

I strongly recommend you use flexbox, which for this example is fairly straightforward. Learn more here: hidden link

Once you have your 3 columns working, you can use the nth-child selector like so to set different widths for the first two items:

.archive-item:nth-child(1), .archive-item:nth-child(2) {
  /* custom width style */
}
#610435

Wow, what a detailed and helpful response! I've really been impressed with the high quality support from everyone at WP Types. I'll try this and come back, but it sounds like this would solve the issue, thanks Nigel!

#610637

Nigel
Supporter

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

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

Hi John

Good luck, and let me know how you get on when you try this.