admin管理员组

文章数量:1301541

So, we used to have this user meta field that stored a single ID to a post. I'm working on rewriting it so it can have multiple IDs to posts. So a single user can have multiple posts in that field. This all works, shows and stores correctly.

I had:

                $meta_query = array(
                    array(
                        'key' => 'meta_field',
                        'value' => $value,
                        'compare' => '='
                    ),
                );

Which worked. How do I now search for example post ID '25688' in a meta field that is

"a:2:{i:0;s:5:"25688";i:1;s:5:"26974";}"

in DB.

I guess I could do a LIKE, but that seems prone to errors once you tick up a digit. Also won't allow me to search for multiple values at once like an IN would allow me to do.

This doesn't seem to be complicated, but has me stumped.

本文标签: Search for value(s) in meta field for a multi select