Display Alternate Content When Looper is Empty

I have a custom post type (ACF) with a custom taxonomy. I have a page with a section containing 3 columns with a headline and a posts element. The posts element is set to be a looper provider using query builder set to pull from my CPT and each posts element pulls from one of the CPT categories.

When there is no posts I would like to display a simple text message in place of the posts. I have a headline element with the message with conditions set to display if provider empty. It shows correct in the Cornerstone preview, but is not displaying on the frontend. Currently I have the headline added inside the Posts > Post > Article element. What am I missing to get this to work. In other pages and on other sites, I’ve gotten this to work using provider output. Is it the ACF source causing the condition not to be met?

Hello Kevin,

Thanks for writing in!

You will have to enable the Looper Provider in the Section Element. You can then insert another Column element that will only display when there is no provider output. Perhaps this sample element structure can help you:

Section - Looper Provider
    Row - 
         Column - 
               Headline
    Row - 
         Column - Looper Consumer
               Headline - Post Title
               Text - Post Content
         Column - with a condition that display when No Provider output
               Headline - "No post item returned."

Hope this makes sense.

I’ll give this a try.

Hey Kevin,

That’s great and let us know how it goes.

Thank you.

Looking at your example structure won’t work for my current layout. I have the following:

Section
    Row -
        Column 1 - Looper Provider - Query Builder - set to CPT and taxonomy term 1
            Headline
                Posts - Looper Provider - 
                    Figure
                    Article
                        Headline - The Title
                            sub-head - Post Date
                         Headline - alternative content
        Column 2 - Looper Provider - Query Builder - set to CPT and taxonomy term 2
            Headline
                Posts - Looper Provider - 
                    Figure
                    Article
                        Headline - The Title
                            sub-head - Post Date
                         Headline - alternative content
        Column 3 - Looper Provider - Query Builder - set to CPT and taxonomy term 3
            Headline
                Posts - Looper Provider - 
                    Div - Figure
                        Image
                        Icon
                    Div - Article
                        Headline - The Title
                            sub-head - Post Date
                         Headline - alternative content

I have each column displaying the posts from a single taxonomy term. I have added a screenshot from the Cornerstone editor of the page section:

Hello Kevin,

I do not see a Looper Consumer in your structure. If I am doing that, it will be like this:

Section
    Row -
        Column 1 - Looper Provider - Query Builder - set to CPT and taxonomy term 1 - Condition: Looper Provider is not empty
            Headline
                Posts * Looper Consumer *
                    Figure
                    Article
                        Headline - The Title
                            sub-head - Post Date
                         Headline - alternative content
        Column 2 - Looper Provider - Query Builder - set to CPT and taxonomy term 2 - Condition: Looper Provider is not empty
            Headline
                Posts * Looper Consumer *
                    Figure
                    Article
                        Headline - The Title
                            sub-head - Post Date
                         Headline - alternative content
        Column 3 - Looper Provider - Query Builder - set to CPT and taxonomy term 3 - Condition: Looper Provider is not empty
            Headline
                Posts * Looper Consumer *
                    Div - Figure
                        Image
                        Icon
                    Div - Article
                        Headline - The Title
                            sub-head - Post Date
                         Headline - alternative content

Hope this helps.

Thanks, I think I had a typo in my response. I had the provider on the column and the consumer on the post. Still not displaying the alt content when the provider is empty. I have included a screenshot of the outline view from Cornerstone.

2024-08-27 17 05 27

Hi Kevin,

If you have already assigned the Looper Consumer and still it is not working, we need to check it through the WordPress admin dashboard. I would suggest you, please provide login credentials for your site in a secure note to examine it further, including:

– WordPress Site URL & Login URL
– WordPress Admin username/password
– Specific page where you have added this structure.

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

Thanks

I will need to pull over a copy of the site to a dev install. I’ll update when it is ready for you.

Thank would be great Kevin.
Just do not forget to share the WP Access of the staging site so we can investigate it.

I’ve added the secure note with login info.

The first column does not have the alt content or settings, only columns 2, 3.

Hello Kevin,

I have gone through several of the pages on your site and I could not find the page that resembles the screenshot in your previous post. I also checked the Bids custom post type and it seems that there are no items added yet. Please double-check.

Thanks.

I have updated the secure note with the url. There were no bids when the data was copied to dev. I restored a previous RFI bid to have a sample. If you preview or view the page, the column is blank instead of showing the alt content. The page should be displaying 1 bid under the open RFIs and the alt content for the other two columns.

The condition for “Provider is Empty” should not be inside a consumer. If you see this structure it uses the “Provider is Empty” check. Your third column did not have a Looper Provider, but the structure should be changed similar to this as well. You’ll see the second column works fine now on your live site. Let us know if this helps and have a great day.

image

image

Great! I’ll take a look and reply back if further assistance is needed.

The alt content now displays when the looper is empty for col 2, but the post no longer is displaying when the looper contains posts, just the icon/image.

It should be:
Looper not empty ; [figure/icon] [dc post title & date]
Looper empty: [alt content]

I’m continuing to fiddle with it in the meantime.

Edit
Sorry for the multiple updates. I believe I have this solved and working for how I want. I needed to re-org some of the elements you created to put them all inside the same container that contains the looper consumer. You had the post date/title outside the consumer. I’ll update if additional assistance is needed.

That’s great news Kevin!

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