# Fill a Fluent Forms Drop-Down With Your Posts

> Fills a Fluent Forms drop-down with the titles of your published posts, pages or a custom post type, so the options stay in sync with your content.

- Type: PHP
- Runs: Run everywhere
- Category: [Forms](https://wpide.com/library/category/forms/)
- Tags: fluent-forms, dynamic, select
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/fluentforms-dropdown-from-posts/

## Code

```php
add_filter( 'fluentform/rendering_field_data_select', function ( $data, $form ) {
    $class = isset( $data['settings']['container_class'] ) ? (string) $data['settings']['container_class'] : '';

    if ( ! preg_match( '/\bwpide-posts-([a-z0-9_-]+)\b/', $class, $m ) || ! post_type_exists( $m[1] ) ) {
        return $data;
    }

    $cache   = 'wpide_ff_choices_' . $m[1];
    $options = get_transient( $cache );

    if ( false === $options ) {
        $options = array();
        $ids     = get_posts( array( 'post_type' => $m[1], 'post_status' => 'publish', 'numberposts' => 200, 'orderby' => 'title', 'order' => 'ASC', 'fields' => 'ids', 'no_found_rows' => true ) );
        foreach ( $ids as $id ) {
            $title     = wp_strip_all_tags( get_the_title( $id ) );
            $options[] = array( 'label' => $title, 'value' => $title, 'calc_value' => '' );
        }
        set_transient( $cache, $options, HOUR_IN_SECONDS );
    }

    $data['settings']['advanced_options'] = $options;

    return $data;
}, 10, 2 );

add_action( 'save_post', function ( $post_id, $post ) {
    delete_transient( 'wpide_ff_choices_' . $post->post_type );
}, 10, 2 );
```

## Notes

Add the container class wpide-posts-<post type> (for example wpide-posts-page) to the drop-down in its Advanced Options.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Fill a Fluent Forms Drop-Down With Your Posts" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
