Looper with conditions repeating first item

My Content Looper displays the first result twice when using conditions.
I have a custom event type for events and want to display all events where the end date (custom field) is after today. This ensures past events are automatically removed. The setup works, however, when using ‘after’, it always duplicates the first event before displaying other future events. It doesn’t duplicate any other events.
If I change the item count to ‘1’, the duplication goes away.
If I select ‘before’, it displays all past events correctly.
If I remove the date condition completely, it shows all the events correctly.
I am using the conditions datetime feature. The custom field with the date is just a normal text field that outputs the date in the format: 12 March 2021.
What could be causing this? See the screenshot.

A quick follow up to this issue.
I tested this with the standard blog post looper and set the condition - publish date before 12 December 2020. This repeated the first item again. By changing ‘before’ to ‘after’, there was no repeated first item.

Hello @Innovatek,

Thanks for writing to us.

In order to help you with your concern, please share your details in a secure note. Please provide the following details

  • WordPress Login URL
  • Admin level username and password
  • Exact Page URL
  • Exact Layout Name

You can find the Secure Note button at the bottom of your posts

Thanks

Hi Prakash,
Thanks. I have attached the login details and website pages in the secure note below.
Please note that, while this particular looper grid is in a block editor, I have also tried it directly on a page with the same result. The source is a custom post type I created called ‘Event’.
Here is what the looper list looks like inserted into a page.
For some reason today, the future events did not repeat the first event, it is now doing it with the past events (I changed the condition to ‘before’.

Hello @Innovatek,

You shouldn’t be adding a condition in the Looper Consumer. Be advised that the consumer will display whatever the output of the provider. If the Provider returns 5 items, the consumer must display 5 items. If you want to filter the events, you should do that in your query string. The current query string is post_type=event&post_status=publish&orderby=event-end-date-text&order=DESC. You should make changes to that query string so that your provider will only output the events you’d like to display. Perhaps this codex will help you with your query string:

Best Regards.

Thanks for looking into this.
I only switched to the query string because it was doing the same thing when using the query builder with conditional date output (on the consumer loop). The query builder is not currently able to filter by custom field - and custom field dates. The query builder is also not yet able to sort via custom field.
Unfortunately, the WP Query page reference is very confusing because it outlines the array code, not how to turn that into a query string that works. There are virtually no examples on the web in how to formulate this.

I am pleased that the core of the current query string works.
However, I do need help on how to add the date filter: Display if custom field date is after today.
I have tried a million possible variations that have not worked.
The core string is: post_type=event&post_status=publish&orderby=event-end-date-text&order=DESC.
Here is one of the addon date examples that didn’t work: &meta_key=event-end-date&meta_value=today&meta_compare=>&type=date.
I have two different custom fields that could be used:

  • event-end-date - Date formatted as a Unix timestamp
  • event-end-date-text - Same date formatted in human language. For example, 21 February 2021.
    If needed, I could reformat the date into the required format.

Any help in creating this query string would be much appreicated. I also hope Themco will be adding custom field filters (both text and dates) and order by soon
Thanks
Ken

Hi Ken,

The meta query with type of DATE works only if the date value is stored at the format YYYY-MM-DD and tested with this format. So it might be the reason behind your issue.

Thanks

Thanks. I tried that, however no luck.
I have decided to use a different plugin for this. Content Views Pro is not as modern as Themeco’s loopers, however, it does a great job with filters, date formats, sorting, custom fields and ‘loops’. Would love Themco to check out the simple functionary this plugin has.
I am really looking forward to new feature updates for Themeco’s loopers and will certainly go back once the filters and sorting improves - as I know it will. Overall an amazing update.
Cheers,
Ken

Hi Ken,

Thanks for your appreciation, please stay tuned for succeeding theme updates.

Thanks

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