Title: Query arguments hook not working
Last modified: March 21, 2022

---

# Query arguments hook not working

 *  Resolved [yann1ck](https://wordpress.org/support/users/ja4st3r/)
 * (@ja4st3r)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/query-arguments-hook-not-working/)
 * Hi Aurovrata,
 * I using a dynamic dropdown to show a list of posts, but I want to show draft 
   posts as well. So I wanted to hook in the query using the provided filter:
 *     ```
       add_filter( 'cf7sg_dynamic_select_post_query','test_dynamic_list',10,3);
       /**
       * Filter post query for dynamic dropdown options.
       * @param array $args an arra of query terms.
       * @param WPCF7_FormTag $tag the field being populated.
       * @param string $cf7_key  the form unique key.
       * @return array an arra of query terms.
       */
       function test_dynamic_list($query_args, $tag, $cf7_key){
         //if you have a dynamic dropdown field with posts as list source.
         //$query_args array to filter query arguments used to populate dynamic dropdown of posts.
         //these arguments are passed to the function get_posts($query_args). (codex: https://codex.wordpress.org/Template_Tags/get_posts)
         if('test'!==$cf7_key || 'test-dropdown' !== $tag->name){
           return $query_args;
         }
         //setup your custom query...
         return $query_args;
       }
       ```
   
 * But it is not working for me. I tried to add `$query_args['post_status'] = 'any';`,
   I also tried to limit the numberofposts or just return null to break the query.
   Changing the priority has no effect as well.
 * I at a look at the code and found the deprecated hook `cf7sg_dynamic_dropdown_post_query`(
   [github](https://github.com/aurovrata/cf7-grid-layout/blob/master/public/class-cf7-grid-layout-public.php)),
   which works perfectly fine. So perhaps there is some issue with the new hook?
 * At least for the hook I am using it should just be `$tag`, not `$tag->name`. 
   Not sure if thats true for the `cf7sg_dynamic_select_post_query` hook as well.
 * I am using version 4.12.13, not the beta you provided last week because of the
   textarea bug.
 * Kind regards
    Yannick
    -  This topic was modified 4 years, 2 months ago by [yann1ck](https://wordpress.org/support/users/ja4st3r/).
    -  This topic was modified 4 years, 2 months ago by [yann1ck](https://wordpress.org/support/users/ja4st3r/).
      Reason: Code styling was broken

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

 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/query-arguments-hook-not-working/#post-15479083)
 * Hello Yannick
 * let me check and revert back.
 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [4 years ago](https://wordpress.org/support/topic/query-arguments-hook-not-working/#post-15645144)
 * hey there, sorry for the delay in my reply, have been very busy at work.
 * So checked this, and realised that in the v4 rewrite of the dynamic field module,
   I changed the names of the filters and deprecated the old ones. However, when
   I updated the filter helper I made a mistake. So the helper code you copied was
   simply wrong.
 * I have fixed this in v4.13. You can upgrade manually to [v4.13.0 RC1](https://github.com/aurovrata/cf7-grid-layout/releases/tag/4.13.0rc1)
   from the GitHub repo or wait till I release the new version.
 *  Thread Starter [yann1ck](https://wordpress.org/support/users/ja4st3r/)
 * (@ja4st3r)
 * [4 years ago](https://wordpress.org/support/topic/query-arguments-hook-not-working/#post-15656102)
 * Hi Aurovrata,
 * thank you very much for looking into the issue and fixing the helper code!
 * I will wait for the v4.13 release on wordpress.org and try the new helper function
   🙂

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

The topic ‘Query arguments hook not working’ is closed to new replies.

 * ![](https://ps.w.org/cf7-grid-layout/assets/icon-256x256.png?rev=1834229)
 * [Smart Grid-Layout Design for Contact Form 7](https://wordpress.org/plugins/cf7-grid-layout/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cf7-grid-layout/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cf7-grid-layout/)
 * [Active Topics](https://wordpress.org/support/plugin/cf7-grid-layout/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cf7-grid-layout/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cf7-grid-layout/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [yann1ck](https://wordpress.org/support/users/ja4st3r/)
 * Last activity: [4 years ago](https://wordpress.org/support/topic/query-arguments-hook-not-working/#post-15656102)
 * Status: resolved