Skip Navigation

[Resolved] AJAX filter not working properly

This support ticket is created 6 years, 4 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 80 replies, has 3 voices.

Last updated by nadavR 5 years, 11 months ago.

Assisted by: Beda.

Author
Posts
#620586

I'm assuming that the ones you just linked to are the most or all problematic fields. I can't go into further details as this is already too much to ask from me. I'm trying to think where there would be a query that looks to see if there's a 0 value, I can't think of it but it will be easier to look after you apply the script on staging. So please go ahead to the best of your knowledge to solve this problem with the information you have. If you need access to staging admin, live admin or even FTP, please ask Christian Cox as he has full access as he's looking into many other tickets. I can also give you access as a collaborator on Flywheel if you give me your email address. Just keep in mind, in case you need a fresh copy of the site, you cannot use your migration plugin on the live/staging site, it will not work and most likely even break the site. You will have to download a full backup through Flywheel's dashboard for that.

#620904

I finished crafting this script.

I used Mohammed's script as a base, elaborated it a bit and made it ready for more cases.

Here is how you have to proceed on your own site (I have tested this process twice locally on the first duplicator we received):

1. Create a backup of your site (even if you tested this before on a staging site)

2. Put your site in maintenance mode. It is crucial that no one will call or reach this site during the process, more important even, no one must create any new post or save any field at this time. The site, in this time, should be accessed only by you.

3. Enable Theme Twenty Seventeen

4. In my tests, I had Toolset only enabled (Views and Types latest stable editions). I suggest you do the same.

5. Update your system (If it is required). Every active Plugin must be updated, as well as the active Theme and WordPress itself

6. Upload this file to the Twenty Seventeen Theme (to the main folder, where index.php and single.php are as well):
https://drive.google.com/file/d/1f2riNaINTqKjRoixiZEj0l4lFj5Wlu0b/view?usp=sharing

- this is a page template
- it has a unique name, you can change that as you wish, but the ending must be ".php"
- the current code in the file is as well commented, you will see that I apply the code to one post type and 2 fields:
Artist, wpcf-music-genre and wpcf-instruments.
These things are defined in 2 variables:
$affected_post_type (one post type a time only)
$affected_custom_fields_meta_keys (several fields connected to above post type)

These are the only 2 variables you will ever edit in this code.

- The Script can be used for ONE post type a time, but SEVERAL Fields (assigned to the same type) at once.
- Only checkboxes fields which saved 0 should be passed in the script.
- In the uploaded file, the script is ready to fix the issue for post type "Artist" and fields "wpcf-music-genre, wpcf-instrument"
- If you have more such fields (checkboxes that saved 0) please add them to the comma-separated list
- for any other post type, please change the $affected_post_type variable in the script and the affected_custom_fields_meta_keys if needed, and re-run the script

7. To actually run the script, I made it very safe.
- You need to create a page (after you uploaded the file to the theme)
- In the page Attributes of the new page, choose the Page template that will appear (name: "Fix It Page")
- save the page
==> As soon you will visit this page on the front end the script will run.
- after running the script, for safety reasons remove the page or disconnect the template

8. Remove the File from the server if needed

9. Head to the Custom Fields you updated during the above steps and immediately save them to "When unchecked, don't save anything to the database"

Please first test this to confirm it works.
Then, even if tested, perform the steps on live sites only after you made sure to have a backup.

It is crucial that you change the Field settings as described in #9, BEFORE you re-open the site for business, so the new posts will all be saved with correct values.

As for if this breaks anything, i did not see that you rely on this 0 value anywhere, so I have great hopes that this is all you need to do.
What I saw thou is you have several checkboxes fields (in other field groups).
In those cases, you would need to re-run the code, after editing the file I submitted you as instructed in #6 above.

Please let me know if there is any issue left.

#621820

Hi Beda,

I followed your steps religiously on the staging site. After I ran the script, and changed the template on that page back to default, and changed the appropriate custom fields value saving settings, everything seemed to work fine on Twenty Seventeen. However, as I re-activated plugins and went back to Newspaper 6 Child Theme, I stopped seeing all grids - the events page is empty, all artist pages are empty, etc. Can you please take a look at my staging site and figure out why this is happening?

Side note: I know you said all themes should be updated, but we are not upgrading to Newspaper 8 - that's not an option for many reasons. But that shouldn't matter to our point anyway, as the grid and filter used to display perfectly before running the script. It's impossible to upgrade to Newspaper 8 without breaking even more functionality on the site, and Newspaper 6 has been stable to us so far.

Thanks,
Nadav

#621826

Hold on. I figured that staging is actually unstable to test this in. So I took the plunge and did this on the live site. It seems to work! Let's keep this ticket up for a few days until AICF staff are certain this is stable, and then I'll mark it as resolved. Thank you!

#622517

Did it work?

#622783

Looks like it's working now! Thanks! I checked with some new posts and it seems fine, will keep monitoring and if something comes up I'll let you know. I, and AICF, appreciate the hard work solving this issue.

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