Custom Looper Provider with nested WP Objects

I would like to create a custom provider that can loop to a certain custom post type and in turn can contain custom WordPress Objects to loop over.

Here is an overview to better understand what I already have:
An Array of WordPress Objects for Campaigns that contain other WordPress Objects to the events in their own Array. (Of Course there are more Campaign Objects)

array (0) WP Object
  'id' = 1234
  'title' = campaign
  ....
  'subloop' array (0) WP Object
              'id' = 1235
              'title' = 'event #1'
              ...
            array (1) WP Object
              'id' = 1236
              'title' = 'event #2'
              ....

I just expanded the found WordPress objects with the ‘subloop’ array, that will show me with the debug-consumer correctly.

But when I want to run a custom provider over this subloop array, I don’t get any data.
Structure of the looper provider and consumer:

section [custom looper provider = campaign]
- row [looper consumer]  (Works as it should)
-- column (Campaign Info)
     "title campaign"
-- column [array looper provider = looper field "subloop"]  (Doesn't work)
---- Output event [looper consumer]
     "title event"

Is it because i use nested WordPress Post Objects?

Hello @Regnalf,

Thanks for writing in! Nested Looper Provider should work in the theme. What are the Looper Providers that you used? To better assist you with this issue, kindly provide us access to the site so we can check your nested loopers. You can create a secure note in your next reply with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
- Confirmation that we can access and make changes to your site

To know how to create a secure note, please check this out: How The Forum Works

Best Regards.

I’ve updated secure note.

As i wrote in my initial post, i use first a custom provider for the main loop, and then use an array provider for the sub field, in my case it is the field [‘proben’].

Hello @Regnalf,

I can see that you are using this alle_proben as your Looper Provider Custom.

I could not find the code in your child theme’s functions.php file. Where did you place this custom Looper Provider code?

Thanks.

That’s right, this page uses a lot of self-made code. That’s why I put it in a separate php file. See the secure note.

Hi @Regnalf,

I have checked your code and it seems that key in the dynamic content tag {{dc:looper:field key=“proben”}} is missing in the response. If the proben key is not present in the response, it will not show in the dynamic content. If that is a post meta field, you need to add it into the response separately.

Thanks

What do you mean it’s not there, you can see it already in the debug-consumer output!

Bildschirmfoto 2022-03-21 um 11.02.30
Bildschirmfoto 2022-03-21 um 11.02.00

It’s an array with the sub WP_Post Objects! It’s not an meta key it’s self generated.

Main Looper:
Bildschirmfoto 2022-03-21 um 11.32.40

Sub Looper
Bildschirmfoto 2022-03-21 um 11.33.00

Hi @Regnalf,

Can you please copy your live site to a staging server so we could troubleshoot freely without breaking your live site?
And give us access in the secure note including:

– WordPress Site URL & Login URL
– WordPress Admin username/password
– FTP/CPanel credential to access the files.

To create a secure note, click the key icon underneath any of your posts.

Thanks

It’s still a development site, so you can use the credentials as given in the SN.

Hello @Regnalf,

We have investigated your issue and we found out that what you are trying to do is beyond the limits of the Looper provider feature built-in the theme. There does seem to be some misconceptions on how the different looper types work though, so here are some things that may help:

  • The Looper Provider Array type expects a string key like “name” and will grab that field from the current looper item. The value there shouldn’t contain Dynamic Content
  • If the looper consumer is a PHP object instead of an array, the values won’t be accessible via {{dc:looper:field}}
  • If contents of the Looper Consumer are a WordPress Post object, it should be available using the normal Post statements like {{dc:post:title}}

Hope this helps.

I already thought that it has something to do with the WP object. But I wanted to try it anyway, because the provider has displayed it correctly.

Anyway, plan B. I will do it either with a second own provider or with a query string.

Thanks :+1: @ruenel, and maybe you could add it to the bottom of the wishlist.

You are most welcome. Yes, I will forwarded this to our developer.

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