Skip Navigation

[Resolved] Use Toolset Date field in Advanced Post Query

This support ticket is created 2 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 5 replies, has 2 voices.

Last updated by Shane 2 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#2288725
Screenshot_2.jpg

I have installed the Advanced Post Queries plugin as I need to filter the Elementor Posts Widget so only current and/or future posts are visible based on the Toolset CF "datum-infomoment" (date event).
However, the settings you see in the screenshot show up empty.

#2288765

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Kristof,

Thank you for getting in touch.

Our custom date fields are stored as timestamps rather than an actual date, so performing the query as a date won't work.

Try setting the query to orderby a number. Also ensure that the field slug is prefixed with wpcf-

Please let me know if this helps.
Thanks,
Shane

#2288783

Hi Shane,
Thank you for picking this up so quickly. It seems I am trying to do 2 things Elementor can't do natively in the Posts Widget:
- Order posts by Toolset Custom Date Field
- Filter posts by Toolset Custom Date Field

To Filter out the 'past' events I have the Advanced Post Queries plugin but I can only enter a Custom Field Name (wpcf-datum-infomoment). I cannot define that as date or number in the settings.

To Order the posts, I am trying to use the Elementor Custom Query function (maybe I should do both exclude and order via the custom query)

function my_custom_events_query( $query ) {
	$query->set( 'orderby', 'wpcf-datum-infomoment' );
}
add_action( 'elementor/query/my_custom_events_query', ' my_custom_events_query' );

I know I can make my custom view which offers both order and filter quite easily, but then I can't style the output using Elementor Loop / Elementor Custom Skin.

#2288801

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Kristof,

I was advising based on the screenshot where you had the field being ordered by a Date.

Perhaps you will need to seek additional assistance from the elementor support team on this one, however you can try doing the following.

function my_custom_events_query( $query ) {
    $query->set( 'orderby', 'meta_value' );
    $query->set('meta_key', 'wpcf-datum-infomoment');
    $query->set('order','ASC');
}
add_action( 'elementor/query/my_custom_events_query', ' my_custom_events_query' );

Thanks,
Shane

#2288815

The Order By has Date by Default, other options are Title, Menu Order, Random. None of these work for me. Custom Field is unfortunately not an option there.

The code you provided does not change anything about the Order 🙁
It seems to have no impact whatsoever, even if I add

$query->set( 'post_type', [ 'custom-post-type1', 'custom-post-type2' ] );

which should cause no results to shop up on hidden link

Is there a way I can use the Elementor Builder inside the Views plugin to build the loop?

#2288821

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Kristof,

In such a case you will need to get assistance from either the Elementor support team or the Advanced Post Queries team.

Is there a way I can use the Elementor Builder inside the Views plugin to build the loop?

Unfortunately no you won't be able to use an elementor template inside your view through conventional means.

However I did stumble upon this documentation from elementor.
hidden link

I've not tested this but you can check to see if it works.

Thanks,
Shane

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.