Array to string error when using dynamic search variable
-
<?php $product_id = get_the_ID(); // Replace with your product ID
$product_post = get_post($product_id);
$post_title = $product_post->post_title; if (is_array($post_title)) {
$post_title = implode(' ', $post_title); // Convert array to string
} $post_title = trim(sanitize_text_field($post_title)); $args = array(
's' => $post_title,
'post_type' => 'post',
'posts_per_page' => 4,
'relevanssi' => true, );This is my current query I run relevanssi with, however I have error (image)
I made sure that the title is not an array as you can see, however when i set static word instead of variable
eg:
‘s’ => ‘keyword’
this works correctly and no error shows.
Where could be the issue? I’m missing something?
I also tried using relevassi do query function, same result
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Array to string error when using dynamic search variable’ is closed to new replies.