Hello,
When I choose my categories in the “listing” page or “request” page, it doesn’t work and I get a critical error, as shown below.
This is the URL of the issue: https://molnee.com/?_sort=&s=&post_type=hp_listing&latitude=&longitude=&_category[]=0&_category[]=1647&location=&goingto=Koh+Samui&date=&price[]=&price[]=
Do you know how to fix this error? Thank you very much.
andrii
January 12, 2024, 10:27am
3
Hi,
Please disable third-party plugins and customizations (if there are any) and check if this issue persists. If you use a caching plugin, ensure that caching is disabled for logged-in users. Also, if the error persists, I recommend that you check your PHP logs, there will be more detailed information there How to configure WordPress error logs to identify and resolve problems - HivePress Help Center
I believe this will be useful to you.
Thx for the advice.
I have something like this. I download the plugin Error Log Monitor and it show me that.
How I can solve it?
Fatal error: Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, array given in /srv/htdocs/wp-content/plugins/hivepress/includes/fields/class-text.php:175
Stack Trace
1.
trim(Array)/srv/htdocs/wp-content/plugins/hivepress/includes/fields/class-text.php:175
2.
HivePress\Fields\Text->normalize()/srv/htdocs/wp-content/plugins/hivepress/includes/fields/class-field.php:382
3.
HivePress\Fields\Field->set_value(Array)/srv/htdocs/wp-content/plugins/hivepress/includes/forms/class-form.php:332
4.
HivePress\Forms\Form->set_value(‘_category’, Array)/srv/htdocs/wp-content/plugins/hivepress/includes/forms/class-form.php:317
5.
HivePress\Forms\Form->set_values(Array)/srv/htdocs/wp-content/plugins/hivepress/includes/components/class-attribute.php:1724
6.
HivePress\Components\Attribute->set_search_query(Object(WP_Query))/wordpress/core/6.4.2/wp-includes/class-wp-hook.php:324
7.
WP_Hook->apply_filters(NULL, Array)/wordpress/core/6.4.2/wp-includes/class-wp-hook.php:348
8.
WP_Hook->do_action(Array)/wordpress/core/6.4.2/wp-includes/plugin.php:565
9.
do_action_ref_array(‘pre_get_posts’, Array)/wordpress/core/6.4.2/wp-includes/class-wp-query.php:1881
10.
WP_Query->get_posts()/wordpress/core/6.4.2/wp-includes/class-wp-query.php:3824
11.
WP_Query->query(Array)/wordpress/core/6.4.2/wp-includes/class-wp.php:696
12.
WP->query_posts()/wordpress/core/6.4.2/wp-includes/class-wp.php:816
13.
WP->main(‘’)/wordpress/core/6.4.2/wp-includes/functions.php:1336
14.
wp()/wordpress/core/6.4.2/wp-blog-header.php:16
15.
require(‘/wordpress/core…’)/wordpress/core/6.4.2/index.php:17
16.
{main}
thrown in /srv/htdocs/wp-content/plugins/hivepress/includes/fields/class-text.php on line 175
I’ve found the error, it’s a php code to make category filtering nicer.
I need this code for select more than 1 category.
Can you please help me fix these 2 codes? Thank you very much.
Listings page
add_filter(
'hivepress/v1/forms/listing_filter',
function( $form_args, $form ) {
if(isset($form_args['fields']['_category'])){
$form_args['fields']['_category'] = array_merge(
$form_args['fields']['_category'],
[
'label' => 'Categories',
'type' => 'select',
'multiple' => true,
]
);
}
return $form_args;
},
1000,
2
);
Requests page
add_filter(
'hivepress/v1/forms/request_filter',
function( $form_args, $form ) {
if(isset($form_args['fields']['_category'])){
$form_args['fields']['_category'] = array_merge(
$form_args['fields']['_category'],
[
'label' => 'Categories',
'type' => 'select',
'multiple' => true,
]
);
}
return $form_args;
},
1000,
2
);
Ok I found the conversation: How to change categories field type in the filtrable zone and you are suggesting to use this snippet code.
But i have trouble with the click (working but not well on mac), any solution for using with multiple choice. Thx a lot
add_filter(
'hivepress/v1/forms/listing_filter',
function( $form_args, $form ) {
if(isset($form_args['fields']['_category'])){
$form_args['fields']['_category'] = array_merge(
$form_args['fields']['_category'],
[
'label' => 'Categories',
'type' => 'select',
]
);
}
return $form_args;
},
1000,
2
);
andrii
January 15, 2024, 9:52am
9
Hi,
I see. Unfortunately, there is no simple solution to make a multiple filter by category since categories are essentially used as listing types. As a workaround, we recommend using select multiple attributes and using categories for other purposes.
Thank Andrii, I get it! Thx again.
system
Closed
February 14, 2024, 3:51pm
11
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.