Skip Navigation

[Resolved] 'Low to high' Sorting is showing properties out of sequence. High to Low is fine

This support ticket is created 4 years, 7 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9: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: Africa/Casablanca (GMT+01:00)

This topic contains 13 replies, has 3 voices.

Last updated by danielM-30 4 years, 7 months ago.

Assisted by: Jamal.

Author
Posts
#1805043
Sorting options.jpg
Example 1.jpg

Tell us what you are trying to do?
I need help working out why 'low - HIGH' results are not right. Please view screenshots attached.
Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?
hidden link

#1805311

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

The posts are ordered by a field price_score, correct?

I would double-check the data stored for those posts, I'm not sure if you have multiple fields recording price (or if the price field can have multiple values).

If you are sure the data is correct, we would need access to your site to check, so let me request those details from you.

I will mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site

#1805757

Hello Dan,

I tried to login on the following URL with the provided user/password, but it did not work.
hidden link

Please double-check the credentials and add FTP credentials, so I can put Adminer and check the database values too.
Your next reply will be private to let you share credentials safely. Or you can update the previous reply.

#1805807

Thank you the credentials are working this time.

But, as the price field is managed by ACF, I'll need to check on the database how it is stored. I need either access to the database or FTP access so I can upload Adminer and use it to check the database.

#1805941

Hi Jamal,
Thank you for looking into this. Once you've logged onto my WordPress you should be able to see the property entries and the structure of the ACF. Please let me know if this isn't enough.

Thank you,
Dan

#1806073

Hello Dan,
I can see what ACF displays on the properties, but I need to check what it stores on the database.
If you cannot allow me FTP access or access to the database, I can take a copy of your website and work on it locally.

#1806081

Sorry, yes please work on it locally.
As I don't know How to access the FTP database. The ACF was just a plugin, so I don't really know how I would get FTP.

#1806301

Currently, the view is ordered by price as a string instead of a number. We have to hook the view's query and change the argument of the query.
You have already a custom code in Toolset->Settings->Custom code. But it does not work for some reason.

I am currently having issues with the local copy. I'll analyze it and get back to you.

#1806847

On my local copy, I had to deactivate all plugins to be able to work, then I activate Toolset Types and Toolset Blocks, and then I activated the snippet that you have in Toolset->Settings and it worked like a charm. Check this screenshot hidden link
You can see that the posts are sorted DESC and you can also see on the underlying SQL query that the order is performed against price_score as a number instead of a string.

Please note, that you have a folder on the plugins (toolset-views-2.8) which hold some infected files according to my antivirus.

Now, on your website, you will have to activate the snippet or add it to the theme's functions.php file. You may need to deactivate the iThemes security plugin while activating the snippet.

#1806857
snippet?.jpg

Is this the snippet within Toolset/settings (image below)?? Will this deactivate once I have deactivated the mentioned plugins? Then afterwards I just need to active everything again and then it should work?

and How do I "add it to the theme's functions.php file."?
Sorry I'm fairly new to web development.

#1806871

We need the code in the snippet to be run. We can run it, either from Toolset->Settings->Custom code, when it is activated. Or we can add it to the theme's functions.php.

Currently, iThemes does not allow the code in Toolset->Settings->Custom code to be run. I thought that if we deactivate iThemes until we activate the code snippet can be enough. If it does not, we'll need to copy that snippet into the theme's functions.php file.

add_filter( 'wpv_filter_query', 'func_orderby_price_numeric', 99, 3 );
function func_orderby_price_numeric( $query_args, $view_settings,$view_id ) {
     
if($view_id == 1936)  {   
 if(!isset($_GET['wpv_view_count'])){  
     $query_args['orderby'] = array( 'meta_value_num');
      $query_args['meta_type'] = 'numeric';   
  }       
  }    
return $query_args;
}

It also seems that you currently have disabled editing PHP files from WordPress. Check this screenshot hidden link

The snippet seems to be active, but it seems that it does not get run. Unfortunately, I can't debug this without having access to files, either through FTP or through cPanel or a similar tool.

#1806879

But how do I get to the 'themes' functions?
Would you mind talking me through

#1806883

Sure, I believe the following articles may explain better:
- hidden link
- https://developer.wordpress.org/themes/basics/theme-functions/

Please note that any code added to the theme's functions.php file may be lost after the theme update. It is preferable to have a child theme. Read more about this on this article https://developer.wordpress.org/themes/advanced-topics/child-themes/

#1809191

My issue is resolved now. Thank you!