Dynamic Content API - Field with prepared and custom value input

I would like to create my own dynamic field that works like the post meta field, for example. Either you select a suggested option from the select field or you can enter your own key.

screenshot_ 2025-11-05 um 15.52.21

Unfortunately, I couldn’t find out from the documentation or the source code of cs whether this functionality was programmed specifically for this purpose or whether there is also an option for it.

Thanks in advance

Hello @Regnalf,

Thanks for writing to us.

In order to help you with your concerns, I would suggest you please have a look at this documentation.

Hope it helps
Thanks

No, that doesn’t help. Before I contact you, I always try to search the documentation, the forum, and even the source code to find an answer.

But as I see it, there are a few things happening in the post meta field example that cannot be found in the PHP files. What I found is that you seem to have defined a predefined control field for postmeta.

screenshot_ 2025-11-06 um 21.24.19

This appears to be filled with values in PHP as well.

But the real magic, which is that you can enter your “own meta key” and an extra field appears if you can’t find the right one in the list, seems to take place in (minimized) JavaScript! But this is almost impossible to read due to the minimization!

screenshot_ 2025-11-06 um 21.31.41

The documentation is still quite sparse when it comes to the possibilities of the Dynamic Content API and understanding what actually happens in the background.


To clarify once again, I would like to create a select field where you can specify your own key, just like with postmeta, if you don’t have the right one in the list.

The basic field already works, except for the missing “Custom Key” option.

public static function REGISTER_FIELD (string $group_name, string $field_name)
{
	
	
	$wp_subsizes = get_intermediate_image_sizes ();
	
	foreach ($wp_subsizes as $subsize)
	{
		self::$o_image_metakeys[]	= ['value' => 'sizes.' . $subsize . '.width',	 	'label' => 'Subsizes - ' . $subsize . ' - Width'];
		self::$o_image_metakeys[]	= ['value' => 'sizes.' . $subsize . '.height',	 	'label' => 'Subsizes - ' . $subsize . ' - Height'];
		self::$o_image_metakeys[]	= ['value' => 'sizes.' . $subsize . '.file',			'label' => 'Subsizes - ' . $subsize . ' - Filepath'];
		
	}
	
		
	cornerstone_dynamic_content_register_field (['group' => $group_name,
																'name' => $field_name,
																'type' => 'mixed',
																'label' => 'Image Meta',
																'controls'	=> [	[	'key' => self::FIELD_IMAGE_ID,
																							'type' => 'text',
																							'label' => 'Image ID',
																							'options' => ['placeholder' => 'Image post_id']
																						],
																						[	'key' => self::FIELD_OPTION__IMAGE_METAKEY,
																							'type' => 'select',
																							'label' => 'Meta',
																							'options' => [	'choices' => self::$o_image_metakeys,
																												'placeholder' => 'Image Meta select']
																						]
																					]
																
																]);
	
}

And it would be awesome if we could use the wp media browser for select images and it’s id’s!

Hi @Regnalf,

What you are trying to acheive requires complex customization, which is beyond the scope of Theme Support. If you still want us to investigate and assist you with this further, I would suggest you avail of our service called One TOTAL CARE, where we offer small customizations.

Thanks

If it is not possible using a simple solution, I understand that you cannot offer custom programming. But that’s not necessary, because I’ve already created some dynamic content fields myself. Except for this specific functionality with the custom meta field when no suitable selection was found. So I only wanted to know whether it is possible using the current built-in tools or parameters of the Dynamic Content API.

And the question regarding the media browser would then be more of a feature request. Because it would be helpful vor built-in dynamic content fields like post or post-title too.

If you set the value of one of your select options as custom, it’ll enter that special mode where you can insert anything. You can also add a customLabel property to your setup of your Dynamic Content control options (or the object where you add self::$o_image_metakeys to choices) and it’ll auto set this up for you. You’re right there is no documentation on this feature, I can start adding that in.

The Dynamic Content controls uses it’s own control system for some reason, but bringing these controls to same system as the Elements is definitely a goal. That way you could have an image select control in the Dynamic Content UI.

Have a great day.

1 Like

Thank you very much @charlie, that’s exactly what I was looking for and it works just as expected. And yes, it would be great if the documentation were a little more detailed.

1 Like

Hello @Regnalf,

Thank you for your feedback. We will share it with our documentation team. We’re glad to hear that @charlie was able to assist you.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.