Skip Navigation

[Gelöst] Can't get sort order to work when using wpv-control

This support ticket is created vor 6 Jahren, 6 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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

Supporter timezone: Asia/Kolkata (GMT+05:30)

Dieses Thema enthält 5 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Minesh vor 6 Jahren, 6 Monaten.

Assistiert von: Minesh.

Author
Artikel
#869503

I've setup a dropdown list to select all dates within a range/year, but when I'm using it, the sort order no longer is affected by the ordering section at the top of the view page. The results seem to be ordering by DESC once a year is selected. I've tried adjusting the following function with ordering, but I haven't been able to get it to make a difference either.

//////////////////////////////////////////
// FILTER THE SCHEDULE BY SELECTED YEAR //
//////////////////////////////////////////
add_filter( 'wpv_filter_query', 'year_func', 20, 3 );
function year_func( $query_args, $settings, $view_id ) {
    if ( $view_id == 305 && isset($_GET['wpv-year'][0]) && !empty($_GET['wpv-year'][0]) ) {
        $start_date = strtotime("01/01/" . $_GET['wpv-year'][0]);
        $end_date = strtotime("01/01/" . ($_GET['wpv-year'][0] + 1));
        $query_args['meta_query'] = array(
            array(
                'key'     => 'wpcf-game-date',
                'value'   => array($start_date, $end_date),
                'compare' => 'BETWEEN',
            ),
        );
    }
    return $query_args;
}

This is what I'm using in the search and pagination section of the view page to generate the dropdown values, to select which year of results need displayed.

[wpv-filter-start hide="false"]
[wpv-filter-controls]
[wpml-string context="wpv-views"]Year:[/wpml-string][wpv-control url_param="wpv-year" type="select" values="[etc-add-years]" display_values="[etc-add-years]"]
[/wpv-filter-controls]
[wpv-filter-end]
#870147

Also, I'm using the new beta version of the toolset plugins.

#871803

Minesh
Supporter

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - I need to check first the code you wrote and what's the outcome of that code.

Could you please share problem URL and access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#876230

Minesh
Supporter

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

Well - i checked and certainly the issue is related to plugin you are using "Post Type Order" as it looks like it hijack the post_orderby hook.

Could you please check with "Post Type Order" author as you already know when you deactivate that plugin, its working just fine.

#877691

I ran through this pretty quickly and overlooked some issues in the code I just posted in my previous post. Even though my main problem went away, there are errors in the code I posted. Please delete my previous post (so no one runs across it and attempts to use it with the errors) and also delete this post, since I don't have the ability to do that.

#881969

Minesh
Supporter

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

Ok fine - I've deleted that post.