Conditional looper provider

Hi there,

First of all my compliments for adding the looper functionality to Theme X Pro. This is exactly what I needed to continue using Theme X Pro. I guess it’s finally time to say goodbye to Elementor :wink:

I’m currently running into an issue whilst designing a global block that containts the looper functionality. My end goal is to achieve the following, namely displaying 3 (no less, no more) testimonials (CPT) on the homepage of my client, that meet the condition of being a “featured” testimonial, which is set by an ACF “true/false” field.

I read the documentation, watched the video’s and read some topics on the forum, but couldn’t find a proper solution. My last attempt was to add a condition ({{dc:acf:post_field field=“featured_testimonial”}} = 1) to my column that contains the looper consumer, but by doing that, I completely lose control of how many featured testimonials are displayed, because the ones that are being hidden are also counted.

Please let me know what I should to to overcome this issue.

Hey @Hindrik,

First off, thank you for your feedback. We’re happy to hear that you like the looper feature.

Regarding the issue, I tested the setup you described and I believe what you’re missing which is a key part is the consumer number.

Set the Looper Consumer to Many.

image

Then, set the number to 3.

image

If that doesn’t help, please give us the following info in a Secure Note.

  • WordPress Login URL
  • Admin username and password
  • URL of the page where you output the testimonials

You can find the Secure Note button at the bottom of your posts.

Thanks.

Hi @christian,

Thank you for the quick reply. Unfortunately changing the Looper Consumer items to Many does not solve the problem. The main issue is, that the column that contains the Looper Consumer also contains a condition, namely {{dc:acf:post_field field=“featured_testimonial”}} = 1. In other words, it grabs 3 items, but hides an item if “featured” is set to false (or 0). The condition should be placed before the content is grabbed, so I think I might have to do something ad the Looper Provider.

I will reply with a secure note so you can check it out.

Hi @Hindrik,

Yes, you are right! If you set the limit to 3, then it will only fetch the first 3 posts that meet your condition {{dc:acf:post_field field=“featured_testimonial”}} = 1. But if you set the looper consumer to All then it will display your data with your condition within the first 10 posts. The reason why it is not showing the way you wanted because of our Looper Provider, which we need to query the meta query in order for them to display properly without the condition you set in your columns. Query builder doesn’t support meta queries and it will require some more customization to achieve your goal.

Regretfully, customization is outside the scope of our theme support. You may seek 3rd party developers to help you with your problems or you can avail One where we can answer questions outside of the features of our theme.

Or if you want some solution but not advisable, we need some help with CSS. Here’s my suggestion:

1.) Just go with your current implementation, just change the Looper Provider from many (3) to All
2.) Then hide all your columns and just display the first 3 columns. Just add the code in your column > customize > edit CSS

 //hide all columns
$el {
  display: none;
}

//display only first, second and third columns
$el:first-child, $el:nth-child(2), $el:nth-child(3) {
  display: block;
}

Hope that helps.

Thank you.

Hi @marc_a,

This is not true. By doing this it will fetch the first 3 posts and then hide/show them based on the condition. Exactly this is the problem.

Hello @Hindrik,

You are using this WP Query for your Looper Provider: post_type=testimonial&type_referentie=1. You will need to add into your query the condition that the testimonial has a featured image or not. Please check out this thread to know more how you can throw in a more complex query so that only the items that has a featured images will be returned by the Looper Provider:

Best Regards.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.