Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter davidnde

    (@davidnde)

    If you follow the post linked above, you will notice this problem is different. The problem is, that each value of $values = get_post_meta($post->ID, $field, false); can be of mixed type. At least people use arrays as values.

    So, what is the best way to serialize these values? I am not quiet sure. What types are actually stored as meta-data. Only strings and arrays?
    At least a would like to see something like:

    $values = get_post_meta($post->ID, $field, false);
    
    foreach ($values as $value) {
      // Custom field values are simply tacked to the end of the post content
      $post->post_content .= ' ' . (is_array($value)? implode(' ', $value) : $value );
    }

    Plugin Author Mikko Saari

    (@msaari)

    Yes – the get_post_meta() call must have the ‘false’ to make sure all meta fields with the same name are returned.

    I suppose there’s an assumption that meta fields only have strings. I’ve never even considered anything else myself, so perhaps I’m just biased.

    That correction of yours does the trick, I suppose.

    Thread Starter davidnde

    (@davidnde)

    Thank you, I see 2.9.1 already implemented it. Thank’s a lot!
    closed…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Relevanssi – A Better Search] Bug Report: wrong use of get_post_meta’ is closed to new replies.