I have a meta_query where I am getting children of a page, I am trying to only get children where the meta key is not the same as the posts title

$args = array(
  'posts_per_page' => -1,
  'parent'         => $post->ID,
  'post_type'      => 'post_type',
  'post_status'    => 'publish',
  'sort_column'    => 'menu_order',
  'meta_query'     => array(
      'key'     => 'my_acf_key',
      'value'   => [how do I add the post title here]
      'compare' => '!=',
  $result = new WP_Query($args);

I am willing to do a custom query, but I was hoping there would be a way to do this with the WP_Query function (that and I have no idea how to even think about building the custom query with the joins necessary to get both tables searched)

I would just get them all and filter after the result is fetched, but I am querying a few thousand fields so the time delay is noticeable

  • 3
    Unfortunately this simply isn't possible via WP_Query. It's just not smart enough under the hood.
    – vancoder
    Aug 5 at 20:33
  • Something like get_the_title(wp_get_post_parent_id($post->ID))? Aug 6 at 1:01


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.