I am trying to use the custom looper to randomly pull 1 post from a post list, or from JSON used within the looper. However, when trying to get the custom looper example to work, I am not seeing any result on the front end.
I have a Div set up as a looper provider set to custom looper with the hook set to my_data (as per the custom looper example)
I have a text element as a looper consumer and the content of the text element as {{dc:looper:field key=“text”}}
I then have the following code in the functions.php file of the 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.’ ],
];
});
Nothing is showing up in the text element. I’m sure I’m missing something very simple, but I can’t seem to work it out.
Ideally I would be able to set up the custom looper, and then use a parameter from the filter to create a random number for the offset of a list of posts within the range of post IDs. But, until I can get the custom looper functional, I’m stuck.