Title: Missing meta_query
Last modified: August 21, 2016

---

# Missing meta_query

 *  [AACT](https://wordpress.org/support/users/aact/)
 * (@aact)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/missing-meta_query/)
 * If you try to filter by customfield_name/customfield_value and also have customfield_orderby
   set, nothing seems to be shown. One or the other works.
 * Looking at your code you seem to have a bug around line 101 in CatList.php
 * No meta_query is set for the customfield_name/customfield_value pair. I think
   they need to be in an array which is itself in an array ‘meta_query’ in $args.
 * See examples of WP_Query definition in the Codex- the format is like:
 *     ```
       'meta_query' => array(
              array(
                  'key' => 'age',
                  'value' => '24',
                  'compare' => '=',
              )
          )
       ```
   
 * Thanks for an otherwise very useful plugin.
 * [https://wordpress.org/plugins/list-category-posts/](https://wordpress.org/plugins/list-category-posts/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Fernando Briano](https://wordpress.org/support/users/fernandobt/)
 * (@fernandobt)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/missing-meta_query/#post-4688098)
 * I tried this code on my test blog:
    `[catlist excludeposts=this customfield_orderby
   =Comics customfield_name=Comics customfield_value="DC" customfield_display=Comics]`
 * And I get the only 2 posts which have their custom field “Comics” set to “DC”.
   If I change it to “Marvel”, I get the posts which have their custom fields set
   to “Marvel”. And the display works too.
 * Perhaps you were trying to filter by more than one custom field value?
 *  Thread Starter [AACT](https://wordpress.org/support/users/aact/)
 * (@aact)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/missing-meta_query/#post-4688130)
 * Hi, thanks for taking a look so quickly.
    No, I wasn’t trying to filter by more
   than one custom-field value.
 * My query is
    [catlist customfield_orderby=rva_firstname customfield_name=rva_persontype
   customfield_value=Staff]
 * i.e. I want all the people who are members of staff, with the list ordered by
   their first names.
 * Your code puts a meta_key into $args of rva_persontype at around line 101 in 
   CatList. It then overwrites this further down with rva_firstname when it looks
   at the customfield_orderby.
 * I can’t see anywhere that you are putting a meta_query into $args, which is what
   is needed to do the customfield_name,custom_field_value matching[at least when
   meta_key is also needed for use with the orderby]
 * I’ve patched CatList.php and it seems to work fine now.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Missing meta_query’ is closed to new replies.

 * ![](https://ps.w.org/list-category-posts/assets/icon-256x256.png?rev=2517221)
 * [List category posts](https://wordpress.org/plugins/list-category-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/list-category-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/list-category-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/list-category-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/list-category-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/list-category-posts/reviews/)

## Tags

 * [catlist](https://wordpress.org/support/topic-tag/catlist/)
 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [lcp](https://wordpress.org/support/topic-tag/lcp/)
 * [orderby](https://wordpress.org/support/topic-tag/orderby/)

 * 2 replies
 * 2 participants
 * Last reply from: [AACT](https://wordpress.org/support/users/aact/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/missing-meta_query/#post-4688130)
 * Status: not resolved