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.
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
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.
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
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?
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