WP_Query using meta_query with LIKE doesn't return what it should

I am using this code to get stuff based on my custom field and custom content type.

$searchTerm = 'bestafricanvideos';

$args = array(
    'post_type' = 'sitemaps',
    'posts_per_page' = -1,
    'meta_query' = array(
        array(
            'key'     = 'cstm_sitemap_url',
            'value'   = $searchTerm,
            'compare' = 'LIKE',
        ),
    )
);

print_r($args);

$the_query = new WP_Query( $args );

if ( $the_query-have_posts() ) :

    while ( $the_query-have_posts() ) : $the_query-the_post();

        $video_url = rwmb_meta('cstm_sitemap_url');
        print_r($video_url);

    endwhile;

else : 

    echo "No video URL found";

    exit;

endif;

wp_reset_postdata();

print_r($video_url);

And the problem is that nothing is returned.

If I remove the metaquery I get a lot of results.

So, I think the problem is that I have stored the custom meta field in db as an url, for example: http://bestafricanvideos.com/top10.html and my search term is bestafricanvideos so, maybe the LIKE cannot grab it and only something like this: http:// bestafricanvideos .com/top10.html will be grabbed?

Any idea how to fix the meta_query so I can grab stuff that conatain the search term in a longer string (or part of a string)?

Topic meta-query comparison wp-query Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.