Search serialized postmeta value from array

This is the first time am writing anything as such. I have an array that has to search serialized value in the database and return its matching results. Below is my current code that am still working on.

//This is my array
$country = array(128, 191, 158);

//This is my args passed to 
$args = array(
    'post_parent' => 85,
    'posts_per_page' => 10,
    'post_type' => 'page',
    'orderby' => 'menu_order', 
    'order' => 'desc',
    'post_status' => 'publish',
    's' => $keyword? $keyword: NULL,
    'meta_query' => array(
        'relation' => 'AND',
        $country? array('key' => 'country', 'value' => $country, 'compare' => 'IN'): NULL,
        $related? array('key' => 'related', 'value' => $related, 'compare' => '='): NULL
    )
);
query_posts( $args );

//Example of postmeta value in the database
$meta = 'a:6:{i:0;s:2:"20";i:1;s:2:"25";i:2;s:2:"128";i:3;s:2:"191";i:4;s:2:"23";i:5;s:2:"24";}';

Any help or directing me to the right resource will be appreciated.

Related posts

Leave a Reply