# Set Posts Module Query through AJAX

**URL:** <https://community.wpbeaverbuilder.com/t/set-posts-module-query-through-ajax/17075>\
**Category:** Developers\
**Created:** [March 14, 2023, 2:59am UTC](https://community.wpbeaverbuilder.com/t/set-posts-module-query-through-ajax/17075 "2023-03-14T02:59:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zudie](https://community.wpbeaverbuilder.com/letter_avatar_proxy/v4/letter/z/34f0e0/32.png) [@Zudie](https://community.wpbeaverbuilder.com/u/Zudie)\
**Post date:** [March 14, 2023, 2:59am UTC](https://community.wpbeaverbuilder.com/t/set-posts-module-query-through-ajax/17075/1 "2023-03-14T02:59:51Z")

</div>

How do I set the query of a posts module through AJAX?  
I need a custom product taxonomies filter for WC products that updates WC Products on the Shop page though AJAX. I know how to do this with pure WP (no BB), but this site is built with BB and my client wants to be able to change the layout of the posts module over time so I need to be able to modify the query of the Posts module dynamically.

I found this code, but it does not work:  
$module = FLBuilderModel::get\_node\_by\_id( $module\_id );  
$module-\>settings-\>query = $query\_args;  
$module-\>save();

Is this the right approach? Or if not, what else?

---

<div class="post-metadata">

**Author:** ![pross](https://community.wpbeaverbuilder.com/user_avatar/community.wpbeaverbuilder.com/pross/32/883_2.png) [@pross](https://community.wpbeaverbuilder.com/u/pross)\
**Post date:** [March 15, 2023, 12:45pm UTC](https://community.wpbeaverbuilder.com/t/set-posts-module-query-through-ajax/17075/2 "2023-03-15T12:45:31Z")

</div>

Where did you find that code? Genuinly curious.

You need to use the `fl_builder_loop_query_args` filter to adjust the uery in the post module

---

<div class="post-metadata">

**Author:** ![Zudie](https://community.wpbeaverbuilder.com/letter_avatar_proxy/v4/letter/z/34f0e0/32.png) [@Zudie](https://community.wpbeaverbuilder.com/u/Zudie)\
**Post date:** [March 15, 2023, 4:04pm UTC](https://community.wpbeaverbuilder.com/t/set-posts-module-query-through-ajax/17075/3 "2023-03-15T16:04:36Z")

</div>

ChatGPT gave me the code. 😉 It is hit or miss with ChatGPT but sometimes it does steer me in the right direction.

On the filter `fl_builder_loop_query_args`: that works on page load, but I need to repaint/reload the whole module when a new filter value is selected. And I do not want to reload the full page, just posts module.  
Do you have any idea on how to do that?

---

<div class="post-metadata">

**Author:** ![pross](https://community.wpbeaverbuilder.com/user_avatar/community.wpbeaverbuilder.com/pross/32/883_2.png) [@pross](https://community.wpbeaverbuilder.com/u/pross)\
**Post date:** [March 15, 2023, 4:18pm UTC](https://community.wpbeaverbuilder.com/t/set-posts-module-query-through-ajax/17075/4 "2023-03-15T16:18:04Z")

</div>

No I dont think there is a way to do that, not out of the box anyway.

---

<div class="post-metadata">

**Author:** ![Zudie](https://community.wpbeaverbuilder.com/letter_avatar_proxy/v4/letter/z/34f0e0/32.png) [@Zudie](https://community.wpbeaverbuilder.com/u/Zudie)\
**Post date:** [March 15, 2023, 4:51pm UTC](https://community.wpbeaverbuilder.com/t/set-posts-module-query-through-ajax/17075/5 "2023-03-15T16:51:50Z")

</div>

Too bad. That would be a very useful feature.
