Using Custom Looper Provider with external API

I’m following the Looper docs, but when I add the basic add_filter code to my child theme’s functions.php like instructed, it causes a Critical Error on the Wordpress site.

I’m adding this code to my child theme:

add_filter( 'cs_looper_custom_my_data', function( $result ) {
  return [
    [ 'text' => 'This is some text for the first item.' ],
    [ 'text' => 'This is some text for the second item.' ]
  ]
});

I just want to use an existing API URL endpoint to pull a basic set of contact records using JSON data into a looper. Nothing fancy. I can’t tell if I need to enumerate each key in the add_filter code, or if I can reference the keys without defining each one in functions.php.

Hello Matt,

Thanks for writing to us.

The filter hook that you have shared in the code is used to create custom Looper, I went ahead and created custom Looper at my localhost and it works fine at my end. Please note if you want to create a custom Looper you need to use the example code properly. You may check this thread for reference. You may contact a developer who can assist you with your concerns or you can subscribe to One where customization questions are answered. Please remember we don’t provide custom development support. It is out of the support scope.

In case you want to pull the JSON date please have a look at our doc to learn more about how to loop through the JSON data.

You may check the video tutorial as well



Thanks

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