Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Radu 1 year ago.

Assigned support staff: Radu.

Author Posts
September 11, 2019 at 5:51 pm #4555663


I want to populate (pre render) the checkbox field choices with the post titles from a custom post type. I already had this working using the documentation on: hidden link

Now that I have setup WPML for an additional language (I have Dutch as my default and English as additional) and have translated these posts, at first the checkbox field choices were populated with the post titles from both languages.

When I added suppress_filters=0 the checkbox field choices were again only populated with the post titles from one language (default language). This is good for one form but for my English form I want the get the translated English post titles.

Can you maybe help me out how to do this?

The code that I am using is:

add_filter( 'gform_pre_render_7', __NAMESPACE__ . '\\populate_trainings_checkbox' );
add_filter( 'gform_pre_validation_7', __NAMESPACE__ . '\\populate_trainings_checkbox' );
add_filter( 'gform_pre_submission_filter_7', __NAMESPACE__ . '\\populate_trainings_checkbox' );
add_filter( 'gform_admin_pre_render_7', __NAMESPACE__ . '\\populate_trainings_checkbox' );
function populate_trainings_checkbox( $form ) {

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

$field_id = 1;
if ( $field->id != $field_id ) {

$posts = get_posts( 'post_type=training&numberposts=-1&post_status=publish&suppress_filters=0' );

$input_id = 1;
foreach( $posts as $post ) {

if ( $input_id % 10 == 0 ) {

$choices[] = array( 'text' => $post->post_title, 'value' => $post->post_title );
$inputs[] = array( 'label' => $post->post_title, 'id' => "{$field_id}.{$input_id}" );


$field->choices = $choices;
$field->inputs = $inputs;


return $form;

September 12, 2019 at 10:28 am #4560229


Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)


Thank you for reaching out the WPML support!

I just checked this out, looked at the article you attached, but I couldn't find a simple way to make the code work for the translations. Since this is some custom coding (and this is outside of our support scope), you can try to reach out one of the WPML contractors (here you can find some more details in order to make this work as you want.


The topic ‘[Closed] Populate a checkbox field (choices) with post titles from specific language’ is closed to new replies.