Popular post view widget, sort by + where clause
This topic contains 12 replies, has 3 voices, and was last updated by Kiran 8 years, 7 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
October 10, 2017 at 9:37 am #399798
Hi,
I have a CPT where I sort the listing page by a custom field of date type.
With your help I was also able to include “upcoming” functionality so that no outdated items appear. https://wpgeodirectory.com/support/topic/event-schedule-functionality/Could you please help me achieve the same thing inside a widget?
Currently I´m using the Popular post View -widget so I guess I would need to customize the “order by” + “where” clause for the query.Thanks!
October 10, 2017 at 6:44 pm #399875The developers have been alerted and they’ll see if it is possible. They’ll let you know asap.
Thanks
October 11, 2017 at 4:57 am #399944Hi anders,
Please provide us site admin & FTP credentials.
I have to look into current functionally. If it is possible, i will provide you snippet to achieve that.Kiran
October 11, 2017 at 6:06 am #399946Thank you Kiran,
Unfortunately I´m still only at localhost with this.
But I´m using a basic child theme for Directory Starter, trying to customize a “Popular Post View” -widget that is placed inside the GD Home Left Section.I have created a CPT with the GD Custom Post Types -addon then added a custom field (Date type).
Inside the widget I would like to sort by the added custom field of date type and only show upcoming items (where the added custom field is, today or later)
Thanks!
October 11, 2017 at 10:50 am #399986Hi anders,
The widget filtering is used by many GD widgets. So i am not able to provide snippet without checking your custom code & fields.
Kiran
October 12, 2017 at 5:46 pm #400273This reply has been marked as private.October 13, 2017 at 7:04 am #400374Hi There,
You forgot to provide FTP host.
Use following code snippet and let us know how it goes.
function _gd_custom_widget_listings_where_date( $where ) { global $plugin_prefix, $gd_query_args_widgets; $query_args = $gd_query_args_widgets; if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) { return $where; } $post_type = 'gd_vinresa'; // Change post type here $field = 'geodir_avresedatum'; // Change field name here if ( !empty( $query_args['post_type'] ) && $query_args['post_type'] == $post_type ) { $date_now = date( "Y-m-d" ); $date_param = isset($_REQUEST['archive']) ? '<=' : '>='; $table = $plugin_prefix . $post_type . '_detail'; $where .= " AND $table.$field $date_param '$date_now' "; } return $where; } add_filter( 'geodir_filter_widget_listings_where', '_gd_custom_widget_listings_where_date', 10, 1 );Kiran
October 13, 2017 at 9:34 am #400420This reply has been marked as private.October 14, 2017 at 4:18 am #400606Hi There,
I have updated snippet for sorting listing in widget.
Check and let us know.Kiran
October 15, 2017 at 12:08 am #400678This reply has been marked as private.October 16, 2017 at 7:12 am #400798The functions.php under child theme directory was overwritten and it has lost my changes. I updated file on 14th Oct and it shows recently edited on 15th.
BTW i have added snippet again. Check and let us know.
Kiran
October 16, 2017 at 8:04 am #400810This reply has been marked as private.October 16, 2017 at 10:06 am #400837This reply has been marked as private. -
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket