- This topic has 3 replies, 2 voices, and was last updated 1 year, 8 months ago by David.
-
AuthorPosts
-
August 8, 2022 at 4:59 am #2306641Justin
Hey, I am using a media query to pull events onto my home page (created by The Events Cal plugin)
http://justinf27.sg-host.com/ – (scroll halfway down the page)
Is it possible to add the event date as a content source somehow?
Then I can display event dates as well as sort them in event date order (currently, it is set to show the event posted date).
Also – I am using Toolset Plugin to create a members directory. I read in a forum that you can actually create members directory using query loops in Generate Press in a similar way to how toolset works? Do you have any documentation on this? (I assume not as I can’t find any – but thought I would ask). This would be an awesome addition to Generate Press ๐
Thanks for your help.
August 8, 2022 at 6:52 am #2306742DavidStaffCustomer SupportHi there,
at the moment the Query Loop only handles core post meta options, do you know how the plugin is storing the date you want to display ? If its in the Post Meta, then you can use the Content Source: Post Meta and enter your meta keys name.
Can you check with the plugin author and let us know.
August 9, 2022 at 10:10 pm #2308464JustinHey David – this worked well thank you.
Is there an easy way I can filter results by upcoming event date though?
When I filter by parent ID or Author – the order for these first few events is correct. But obviously this will only work if I create events in order that they come up (ie, if I added an event for today, that would show last on the list).
Perhaps I can’t achieve event ordering with the Query loop, and I should just get the events cal pro plugin – just trying to keep the sight as lightweight as possible and achieve this through GP ๐
August 10, 2022 at 5:38 am #2308781DavidStaffCustomer SupportOrderby Custom Field will be something we add in GB Pro in a future update.
But, we use the WP_Query function and we have the
generateblocks_query_loop_args
filter for adding custom parameters to the query.
Try this snippet:add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) { if ( ! is_admin() && // if block has an advanced > additional CSS Class of: orderby-event-date ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'orderby-event-date' ) !== false ) { // pass meta_query parameter $query_args[ 'meta_query' ] = array( 'meta_key' => 'your_event_date_meta_name', 'orderby' => 'meta_value_num', 'meta_type' => 'DATE', 'order' => 'DESC' ); } return $query_args; } );
Note:
1. The
orderby-event-date
is a CSS Class that you need to add to the Query Loop block.
2. Theyour_event_date_meta_name
needs to be replaced with the post meta field name which stores the date. -
AuthorPosts
- You must be logged in to reply to this topic.