Skip Navigation

[Resolved] latest release breaks ordering function

This support ticket is created 7 years, 10 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.

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 25 replies, has 2 voices.

Last updated by justineO 7 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#418742

I can't see the private post to you so I have just changed the password. Not sure if this post is private so not going to include link and username again.

#fGTwK5oMfiiXlWcBYqtBj(F

#418828

Shane
Supporter

Languages: English (English )

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

Hi Justine,

Thank you for the credentials.

I tested the sorting functionality and it seems to work perfectly fine for me.

I'm not able to notice any issue at all.

Thanks,
Shane

#418956
Screen Shot 2016-07-23 at 10.49.21 AM.png

Hi Shane,

Can you please explain or attach a screen shot of what your are seeing as compared to the image I attached.

The directory listing need to be displayed by listing level first, then alphabetically within that. The listing are not appearing alphabetically at all. (see attached M should not come before G). Maybe I was being confusing... see below for how they used to appear:

Featured Listings
A
B
C

Enhanced Listings
A
B
C

Basic Listings
A
B
C

As mentioned at the start of this thread this worked before the recent Toolset update through a function that the Toolset team helped me with. The views only allow me to select a single method for ordering. I cannot update Toolset on my site until resolved as this is a live paid directory.

Thank you,
Justine

#419349

Shane
Supporter

Languages: English (English )

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

Hi Justine,

Thanks for making this a whole lot clearer for me 🙂

Can you try doing this ?

add_action( 'wpv-before-display-post', 'sort_archive', 10, 2 );
 
function sort_archive( $post, $view_id ) {
    if ( $view_id == 3007 ) { 
 
if ($query->is_tax('listings') && $query->is_archive) {
 
$query->set('order','ASC');
 
$query->set('meta_key', 'wpcf-level');
 
$query->set('orderby', 'meta_value title');
}

    }
}

You may need to add it to a view hook.

Please let me know if this helps.
Thanks,
Shane

#419667

Hi Shane,

I added that to my functions file. When I visit a directory page I get the following error:

Fatal error: Call to a member function is_tax() on a non-object in /nas/content/staging/childslife/wp-content/themes/childs-life/functions.php on line 23

#419767

Shane
Supporter

Languages: English (English )

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

Hi Justine,

Thanks for he response, for now i've sought assistance from my colleagues.

There may be a filter we can use to get your custom filter working again.

Thanks,
Shane

#419771

Shane
Supporter

Languages: English (English )

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

Hi Justine,

I have good news.

I've managed to get it to work by adding a priority for when your script should run.


function sort_tax_archive_loop($query) {
 
if ($query->is_tax('listings') && $query->is_archive) {
 
$query->set('order','ASC');
 
$query->set('meta_key', 'wpcf-level');
 
$query->set('orderby', 'meta_value title');
}
}
 
add_action('pre_get_posts', 'sort_tax_archive_loop',100);

This should sort your archive now.

Please let me know if this helps.
Thanks,
Shane

#419788

Hi Shane,

Yes this works. Thanks! Just so I understand what does the ,100 do? (at the end of the add_action).

Justine

#419804

Shane
Supporter

Languages: English (English )

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

Hi Justine,

The 100 actually set the priority. The lower the number the higher the priority of the function.

So I figured that the views new filter was at a higher priority probably 99 so I set it to 100 to make it run before.

Let me know if this helps.
Thanks,
Shane

#420049

Shane
Supporter

Languages: English (English )

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

Hi Justine,

If there are no further questions on this issue then you can proceed to marking this ticket as resolved 🙂

Thanks,
Shane

#423823

Thank for all your help!

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