Skip Navigation

[Resolved] Custom JS had stopped working in a view block

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: Asia/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 1 year, 3 months ago.

Assisted by: Waqar.

Author
Posts
#2653321

Hi!
I'm using a query filter in a view block of 'esemenyek' which filters my results by current date, when loading the page, and it stopped working. I'm not sure what triggered the change, it might be the update of the theme I'm using (Kadence - it updates automticly).
I've tried to:
- upgrade wp and all Toolset plugins to the latest version.
Unfortunately it didn't solve the problem, but it spoiled the template editor in Toolset, so I've downgraded wp to 6.1.1 (at least the template editor is working with this version)
- change to a different theme
Didn't work.
- disable all other plugins except Toolset
Didn't work.
- change the JS code to a simple window.alert()
It seems, the JS code simply doesnt't apply to the page

The link to the site is: hidden link

Thanks
Gabor

The filter which I'm using is as follows:
add_filter('wpv_filter_query', 'remove_past_events', 10, 3);
function remove_past_events($query_args, $view_settings, $view_id) {
if($view_id == 395 && !isset( $_GET['wpv_view_count'] )) {
$time = time();

$query_args['meta_query'][] = array(array(
'key' => 'wpcf-esemeny-idopontja',
'value' => $time,
'compare' => '>=',
'type' => 'NUMERIC,'
));
}

return $query_args;
}

#2653551

Hi Gabor,

Thank you for contacting us and I'd be happy to assist.

Looking into the page's source code, I understand that this code is included in the JS editor of the view.

This is a PHP code and not the JS code so it will not work from within the JS editor. Please remove it and include it through Toolset's custom section.
( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ )

Any custom PHP code snippets included through this section, won't be affected by the theme updates.

This should make the code snippet work as expectedly and let me know how it goes.

regards,
Waqar

#2653815

Dear Waqar,

I think it is obvious, that I'm not a programmer 🙂 However, following your advices I managed to fix the problem. What makes the story very strange, that the code did work earlier, added as custom JS.
Anyway thanks for the support!

Best regards
Gabor