• <?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)
  • Plugin Author Mikko Saari

    (@msaari)

    Which version of WP are you using? I looked at what’s on line 4551 of class-wp-query.php, and at least in the current version, there’s the is_single() function, which has nothing to do with the search. It doesn’t handle the s parameter, so the error is not coming from that. It’s something else.

    What values of s cause this error? The same value should still cause this error even when entered as a static value. It may be related to what results the search returns.

Viewing 1 replies (of 1 total)
  • The topic ‘Array to string error when using dynamic search variable’ is closed to new replies.