Issue: Slider blank with Slide Container Custom Hook

Issue
I’m trying to build a slider that shows 2 reviews per slide (Reviews CPT).
When I set Slide Container → Looper Provider = Custom (Hook) and Slide → Consumer = ON, the slide renders empty. If I turn Consumer OFF, static content shows. So it seems the Slide isn’t receiving items from the Container.

Steps to reproduce

  1. Slider (Stacked) → Slide Container → Slide.

  2. Slide Container: Provider = Custom (Hook: test_slides).

  3. Functions.php:

    add_filter('cs_looper_test_slides', function(){ return [1,2,3]; });
    
  4. Slide: Consumer ON, add text inside.
    → Expected: 3 slides with text.
    → Actual: nothing displays.

Questions

  1. How do I fix this & make it like loop through the Review Post Type, display TWO reviews in one slide. Eg: lets say I have 10 reviews, then it will show TWO reviews in a slide and dynamically show 5 slides.
  2. The Review is in the Section 6 and there are 2 versions of it. One is Slider - BACKUP ( this is static), the other (Slider - FOR SUPPORT) is the looper one for the support

Hello CStaff,

Thanks for writing in!

The filter will be cs_looper_custom_{{your_hook}} , where {{your_hook}} is the replaced with the hook you enter. For example, let’s say you entered the following code into your child theme’s functions.php file:

add_filter('cs_looper_custom_test_slides', function(){ return [1,2,3]; });

Kindly let us know how it goes.

Hi Support Team,

I’m using ACF with Cornerstone’s Looper + Dynamic Content. I have a custom field set as a Post Object (pointing to WooCommerce products). Inside my Review posts, I want to display the related product’s title, price, and image using Dynamic Content.

For example, I tried:

{{dc:post:title id="{{dc:acf:field key='review_product'}}"}}
{{dc:woocommerce:product_price_html id="{{dc:acf:field key='review_product'}}"}}
{{dc:post:thumbnail id="{{dc:acf:field key='review_product'}}"}}

But this doesn’t output correctly when the field Return Format is set to Post Object . It seems that DC is passing the entire WP_Post object instead of the post ID, so it doesn’t resolve the id attribute.

If I change the Return Format to Post ID , then the same DC tokens work fine.

Questions:

  1. Is Dynamic Content expected to support ACF Post Object fields, or is Post ID the only supported return format?
  2. Is there a recommended way to extract the ID from a Post Object inside DC (without needing to switch all fields to Post ID)?
  3. Could this be improved in a future update so that DC automatically detects Post Object and uses its ID (since that’s usually what’s needed for id attributes)?

Thanks for clarifying how Post Object support is intended to work with Dynamic Content.

Best regards,

Hello CStaff,

You may be using the {{dc:post:title id="{{dc:acf:field key='review_product'}}"}} dynamic content incorrectly. Take note that you have:

Slider Container - Looper Provider Custom `review_slides`
  Slide - Looper Consumer 
    Group - Looper Provider Custom `reviews_for_slide`
      Review - Looper Consumer

As for the reviews for slides function;

// 2) Return exactly 2 reviews for a given slide number
add_filter('cs_looper_custom_reviews_for_slide', function ($items, $args) {
  $cpt  = 'review';         // <-- your CPT slug
  $per  = 2;
  $page = isset($args['page']) ? max(1, (int) $args['page']) : 1;
  $off  = ($page - 1) * $per;

  return get_posts([
    'post_type'           => $cpt,
    'posts_per_page'      => $per,
    'offset'              => $off,
    'orderby'             => 'date',
    'order'               => 'DESC',
    'post_status'         => 'publish',
    'ignore_sticky_posts' => true,
  ]);
}, 10, 2);

This will already return post object which means that you do not need to use the {{dc:post:title id="{{dc:acf:field key='review_product'}}"}}. You only need this if you want to display specific post data WITHOUT using a looper. In your use case, the review_product field SHOULD return an ID because that is what is needed by the {{dc:post:title id="123"}} dynamic content.

#1] Dynamic Content supports ACF Post Object fields. The POST ID return format is needed depending on which dynamic content parameter you used it.

#2] Yes, there is. When the ACF field returns a Post Object, you will have to use a Looper Provider Dynamic Content {{dc:acf:field key='review_product'}}. Therefore, your element structure will now becomes:

Slider Container - Looper Provider Custom `review_slides`
  Slide - Looper Consumer 
    Group - Looper Provider Custom `reviews_for_slide`
      Review - Looper Consumer
        DIV - Looper Provider Dynamic Content `{{dc:acf:field key='review_product'}}`
          DIV - Looper Consumer
            Headline - {{dc:post:title}}
            Image - {{dc:post:thumbnail}}

#3] I do not think there is a need to improve here because the {{dc:post:title id="123"}} is pretty much straightforward that it needs the ID value. And this {{dc:acf:field key='field_name'}} dynamic content will always return whatever the return format is set for the field.

Hope this makes sense.

Hi @ruenel,

I tried your suggestion but {{dc:post:title}} & {{dc:post:thumbnail}} ouput empty. I did ensure all the test reviews has the attached product.

Are you sure if this {{dc:acf:post_field field="review_product"}} is the correct syntax? I tried {{dc:acf:post_field field="review_product"}} this but it only displays Review Post not the Product.

Any insights?

Thanks.

Hello CStaff,

If you use {{dc:acf:post_field field="review_product"}} as your Looper Provider Dynamic Content, you will have to change the return format of the ACF field as Post Object.

Please check out the link in the secure note below.

Thanks.

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