Get every post with value in meta key

I am trying to get every post, that has a specific URL in the meta key _cornerstone_data. From the WordPress documentary I was able to build this query, that probably gets me close to what I’m trying to achieve:

$meta_query_args = array(
‘key’ => ‘_cornerstone_data’,
‘value’ => $attachment_url,
‘compare’ => ‘LIKE’,
$meta_query = new WP_Meta_Query( $meta_query_args );

$mysql =$meta_query->get_sql(

The result is an array that looks like this:

‘join’ => string ‘INNER JOIN fx30k_postmeta ON ( fx30k_posts.ID = fx30k_postmeta.post_id )’
‘where’ => string ‘AND ( ( fx30k_postmeta.meta_key = ‘_cornerstone_data’ AND fx30k_postmeta.meta_value LIKE ‘{c6fc…
AND ( ( fx30k_postmeta.meta_key = ‘_cornerstone_data’ AND fx30k_postmeta.meta_value LIKE ‘{c6fc239abf1a24a4f555ce84bb7edf17dd16d1cd29f38c738529c38aafc546ff}{c6fc239abf1a24a4f555ce84bb7edf17dd16d1cd29f38c738529c38aafc546ff}’ )

However, I don’t know what to do with this result and I didn’t find any documentary or tutorial explaining this. How can I further use this, to get the posts that I am looking for?

Read more here:: Get every post with value in meta key

Leave a Reply

Your email address will not be published. Required fields are marked *