• Resolved setick

    (@setick)


    Hi,

    I try to query all posts that have value for a custom filed.

    Let’s say I have a custom field named ‘Bookname’ and I want to get all posts that have bookname values.

    Here is the code:

    $args = array(
    'post_type' => 'post',
    'meta_query' => [
    [
    'key' => 'Bookname',
    ],
    ],
    'posts_per_page' => 5,
    );
    
    $posts = get_crp_posts($args); // show all posts
    
    $posts = get_posts($args); // Works as intended

    CRP shows all posts whether the post has the custom field or not. However, the WP get_posts() works just fine.

    I’ve tried for hours but cannot find out why so I come here for help, thanks.

    • This topic was modified 1 year, 3 months ago by setick.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘meta_query not working’ is closed to new replies.