salwebs
February 9, 2022, 11:52am
1
Bricks Version : 1.3.7
Browser : Chrome 90
OS : macOS / Windows / Linux / etc.
URL : ALQUILER DE BARCO SIN LICENCIA EN MENORCA – Alquiler de barcos y lanchas en Menorca – Ciutadella y Fornells
I think it’s because the loop is empty, bye the message it displays…
salwebs
February 9, 2022, 12:06pm
2
I’ve removed the line 154 from /bricks/includes/elements/code.php
beacuse I need to deliver that site…
Hope is fixed in next update:
timmse
February 10, 2022, 7:10am
3
Hey,
What is inside of your code element?
salwebs
February 10, 2022, 7:57am
4
Hi,
First I have created a bricks template with a query. But I leave the query empty, so from a parent with a defined query and the filter you provide, I can call that template for different queries.
so in the parent query there is that cade
<?php
global $wp_query;
$backup = $wp_query ;
$wp_query = new WP_Query(array(
"post_type" => "bcbs_boat",
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'without_licence',
'value' => "1",
'compare' => 'NOT LIKE',
),
array(
'key' => 'without_licence',
'value' => "1",
'compare' => 'NOT EXISTS',
),
),
//'meta_value' => "1",
));
//list barcos sin query
echo do_shortcode('[bricks_template id="3377"]');
$wp_query = $backup;
?>
Probably the error is because the query is just enabled and didn’t set any parameters. So the error display “query_vars is undefined”…
thanks
Hello @salwebs
And where do you set the query_vars filter?
salwebs:
First I have created a bricks template with a query. But I leave the query empty, so from a parent with a defined query and the filter you provide, I can call that template for different queries.
so in the parent query there is that cade
The logic is correct. You could set a query loop with some standard configuration like query the bcbs_boat posts and then use the filter bricks/posts/query_vars
to fine-tune it on each post. I wouldn’t use the code you posted in your last reply.
Bottom line, it seems it is not a Bricks bug but we would like to help you to find the root cause of the PHP notice.
salwebs
February 10, 2022, 10:29am
6
inside the “empty loop” template.
The “merge vars” has this content:
<?php
add_filter( 'bricks/posts/query_vars', function( $query_vars, $settings , $element_id) {
if ( $element_id === 'ndbhii' ) {
global $wp_query;
return wp_parse_args( $this->query_vars, $wp_query->query );
}
return $query_vars;
}, 10, 3 );
add_filter( 'bricks/posts/merge_query', function( $merge, $element_id ) {
if ( $element_id === 'bvpuao' ) {
return true;
}
return $merge;
}, 10, 2 );
?>
“ndbhii” is the container loop id.
I’ll try
luistinygod:
that line is empty.
153 sorry. “ini_set(‘display_errors’, 1);”
Hello @salwebs
Sorry for the late reply.
There is one error in this line: $this->query_vars
do not exist in that context. You should use $query_vars
.