The issue with using WP_Query

[ad_1]

I have registered metadata for my posts, and the metadata is an array containing numeric elements, for example, [1, 3, 5]. I need to use WP_Query to retrieve a list of posts based on the condition that this metadata array includes a specified value, such as 5. However, the code I’ve written is not successfully fetching the post data, and I’m not sure where the issue lies. I hope you can help me take a look.

$query_args =  array(
  'post_type'  => 'work',
  'posts_per_page' => 10,
  'meta_query' => array(
    array(
      'key' => 'meta_key',
      'value' => 5,
      'compare' => '=',
    ),
  ),
);

$query = new WP_Query($query_args);

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer