# Custom Module: right place to load options for Field Select dynamic before Module rendering

**URL:** <https://community.wpbeaverbuilder.com/t/custom-module-right-place-to-load-options-for-field-select-dynamic-before-module-rendering/17984>\
**Category:** Developers\
**Created:** [November 23, 2023, 4:36pm UTC](https://community.wpbeaverbuilder.com/t/custom-module-right-place-to-load-options-for-field-select-dynamic-before-module-rendering/17984 "2023-11-23T16:36:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mak74](https://community.wpbeaverbuilder.com/user_avatar/community.wpbeaverbuilder.com/mak74/32/4196_2.png) [@mak74](https://community.wpbeaverbuilder.com/u/mak74)\
**Post date:** [November 23, 2023, 4:36pm UTC](https://community.wpbeaverbuilder.com/t/custom-module-right-place-to-load-options-for-field-select-dynamic-before-module-rendering/17984/1 "2023-11-23T16:36:44Z")

</div>

Hello everyone,  
I want to create a select field in a custom module with a query via WP\_Query and custom fields, and a sorting by menu items:

```auto
'items_list' => array(
                        'type' => 'select',
                        'label' => __( 'Items', 'fl-builder' ),
                        'default' => '',
                        'options' => getItems(),
                    ),

```

Here is the query:

```auto
$args = array(
            'posts_per_page' => -1,
            'post_type' => 'cpt_items',
            'suppress_filters' => true,
            'post_parent' => 0,
            'fields' => "ids",
            'orderby' => 'menu_order'
        );
        $items = new WP_Query($args);

```

Where or how do I have to store the query? In the FLBuilderModule class, the query does not give me the correct results, e.g. the sorting “menu\_order” is ignored etc.

Is it generally possible to dynamically set the options for a select field in an “FLBuilder::register\_module”?

Many Thanks

---

<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:** [November 24, 2023, 6:02pm UTC](https://community.wpbeaverbuilder.com/t/custom-module-right-place-to-load-options-for-field-select-dynamic-before-module-rendering/17984/2 "2023-11-24T18:02:45Z")

</div>

WP\_Query returns a WP\_Query object, inside that object is the results of your query, you need to use that and loop them so the options is a name/value array. Plenty of examples in the modules folder.
