<pre class="lang:default decode:true  ">&lt;?php
add_filter( 'gform_pre_render', 'prefix_populate_posts' );
add_filter( 'gform_pre_validation', 'prefix_populate_posts' );
add_filter( 'gform_pre_submission_filter', 'prefix_populate_posts' );
add_filter( 'gform_admin_pre_render', 'prefix_populate_posts' );
function prefix_populate_posts( $form ) {

	$field_class      = 'post-select';
	$post_type        = 'post';
	$placeholder_text = 'Please select one..';

	foreach ( $form['fields'] as $field ) {

		if ( strpos( $field-&gt;cssClass, $field_class ) === false ) {
			continue;
		}

		$posts = get_posts( [
			'post_type'      =&gt; $post_type,
			'orderby'        =&gt; 'post_title',
			'order'          =&gt; 'ASC',
			'posts_per_page' =&gt; '-1'
		] );

		$choices = [];

		foreach ( $posts as $post ) {
			$id = get_post_meta( $post-&gt;ID, 'post_id', true );

			$choices[] = array( 'text' =&gt; $post-&gt;post_title, 'value' =&gt; $post-&gt;post_title );
		}
		$field-&gt;placeholder = $placeholder_text;
		$field-&gt;choices     = $choices;

	}

	return $form;
}</pre>