Skip Navigation

[Resolved] Setting an offset with more than one view on a page

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.

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

Problem:

So I've got a site that has three separate views on it:
1. Latest 5 posts or podcasts (a custom type I made)
2. Latest 5 posts with the category "executive"
3. Latest 5 podcasts

What I want is this, though:
1. Latest 5 posts or podcasts (a custom type I made)
2. Latest 5 posts with the category "executive," excluding any in View #1
3. Latest 5 podcasts, excluding any in View #1

The mixture of Executive posts, non-Executive posts and podcasts is not known from day to day--it varies.

Solution:

There is a workaround for it, for example:
1) Add below codes in your theme/functions.php:

add_shortcode( 'hide-it', 'hide_it_func');
function hide_it_func($atts)
{
    return;
}

It will create a new shortcode [hide-it], we can use it to hide the extra HTML div tag in below view.

2) Create view #4: "view-1-only-ids", with same filters as View #1, but outputs only the post IDs:
a) In section "Loop Output Editor", edit the codes to only one line:

[hide-it][wpv-layout-start][/hide-it][wpv-items-found]<!-- wpv-loop-start --><wpv-loop>[wpv-item index=1][wpv-post-id][wpv-item index=other],[wpv-post-id]</wpv-loop><!-- wpv-loop-end -->[/wpv-items-found][wpv-no-items-found]<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>[/wpv-no-items-found][hide-it][wpv-layout-end][/hide-it]

b) in section "Filter and Loop Output Integration Editor", edit the codes to only one line:

[wpv-layout-meta-html]

So it will output only the post IDs.

3) Edit the view #2 (Latest 5 posts with the category "executive") and view #3 (Latest 5 podcasts, excluding any in View #1), add a filter:
Exclude posts with IDs set by the View shortcode attribute "ids" eg. [wpv-view name="view-name" ids="1"]
https://toolset.com/documentation/user-guides/filtering-views-query-by-post-id/

4) Edit the shortcode of view #2 and view #3 , setup the attribute "ids" as view #4, for example:
[wpv-view name="my-view-name" ids="[wpv-view name="view-1-only-ids"]"]

Then test again.

Relevant Documentation:

This support ticket is created 6 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

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

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 10 replies, has 2 voices.

Last updated by Luo Yang 6 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#607361

Tell us what you are trying to do?
So I've got a site that has three separate views on it:
1. Latest 5 posts or podcasts (a custom type I made)
2. Latest 5 posts with the category "executive"
3. Latest 5 podcasts

What I want is this, though:
1. Latest 5 posts or podcasts (a custom type I made)
2. Latest 5 posts with the category "executive," excluding any in View #1
3. Latest 5 podcasts, excluding any in View #1

The mixture of Executive posts, non-Executive posts and podcasts is not known from day to day--it varies.

What is the link to your site?

hidden link

#607456

Dear Christopher,

There is a workaround for it, for example:
1) Add below codes in your theme/functions.php:

add_shortcode( 'hide-it', 'hide_it_func');
function hide_it_func($atts)
{
	return;
}

It will create a new shortcode [hide-it], we can use it to hide the extra HTML div tag in below view.

2) Create view #4: "view-1-only-ids", with same filters as View #1, but outputs only the post IDs:
a) In section "Loop Output Editor", edit the codes to only one line:

[hide-it][wpv-layout-start][/hide-it][wpv-items-found]<!-- wpv-loop-start --><wpv-loop>[wpv-item index=1][wpv-post-id][wpv-item index=other],[wpv-post-id]</wpv-loop><!-- wpv-loop-end -->[/wpv-items-found][wpv-no-items-found]<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>[/wpv-no-items-found][hide-it][wpv-layout-end][/hide-it]

b) in section "Filter and Loop Output Integration Editor", edit the codes to only one line:

[wpv-layout-meta-html]

So it will output only the post IDs.

3) Edit the view #2 (Latest 5 posts with the category "executive") and view #3 (Latest 5 podcasts, excluding any in View #1), add a filter:
Exclude posts with IDs set by the View shortcode attribute "ids" eg. [wpv-view name="view-name" ids="1"]
https://toolset.com/documentation/user-guides/filtering-views-query-by-post-id/

4) Edit the shortcode of view #2 and view #3 , setup the attribute "ids" as view #4, for example:
[wpv-view name="my-view-name" ids="[wpv-view name="view-1-only-ids"]"]

Then test again.

#607790

So my view showing the IDs is properly generating them, but it's not translating into the other views correctly. See the home page:

hidden link

right above the lead slide show, you can see the IDs being generated, but you'll see that the stories are repeating down in the "Executive Edition" section.

#607838

Which posts are the repeating post?
Please describe detail steps for how and where I can see the problem, thanks

#607851

This one is repeating: Zumiez Founder Tom Campion and His Crazy, Winning Culture

#607854

It works fine in my localhost, please provide a test site with same problem, and fill below private detail box with login details, also point out the problem page URL and view form URL, I need a live website to test and debug, thanks

#608430

Thanks for the details, i can login your website, but I am not sure which one is the view #1 #2, #3 and #4, please point out the view URLs, I need to check you view settings.

#608431

View #1 is Main Slider Owl
View #2 is Podcasts
View #3 is Executive Edition
View #4 is GetHomepageIds (I've tried one or two versions of this--others were view-1-only-ids and list-of-home-ids)

#608438

I simply create a new page with below shortcodes to output each views in a simple page:
hidden link

<h2>View #1 is</h2>
[wpv-view name="main-slider-owl"]
<hr />

<h2>View #2 is Podcasts</h2>
[wpv-view name="podcasts" limit="1" ids="[wpv-view name='gethomepageids']"]
<hr />

<h2>View #3 is Executive Edition</h2>
[wpv-view name="executive-edition" limit="1" ids="[wpv-view name='gethomepageids']"]
<hr />

<h2>View #4 is GetHomepageIds</h2>
[wpv-view name='gethomepageids']

Test above page in front-end:
The view #4 outputs 5 post's IDs:
64986,64995,63980,63982,63988

and view #2 outputs post 63214, and view #3 output post ID 64011, can you check if it is what you want?

If it is, since you are using 35 plugins + custom theme, in case there is any compatibility problem in your website, please check this:
deactivate other plugins and switch to wordpress default theme, and test again, and locate the problem plugin or theme, I suggest you backup your website first.

#608601

Got it! The problem was that we had put the shortcodes into a Divi theme "code" module, and apparently that wasn't rendering it correctly. When we changed it to a text module, your code worked! Thanks!!

#608766

You are welcome

The forum ‘Types Community Support’ is closed to new topics and replies.

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