This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Edit custom field placeholder

#33606
Ernest MarcinkoErnest Marcinko
Keymaster

Might be possible:

add_action('wp_footer', 'wp_footer_change_filter_input_placeholder', 9999);
function wp_footer_change_filter_input_placeholder() {
	?>
	<script>
	(function(){
		let fields = {
			"field-name1": "My placeholder text1",
			"field-name2": "My placeholder text2"
		};
		setTimeout(function() {
			Object.keys(fields).forEach(function(k){
				let text = fields[k];
				document.querySelectorAll('fieldset.asp_custom_f input[name*='+k+']').forEach(function(el){
					el.placeholder = text;
				});
			});
		}, 100);
	}())
	</script>
	<?php
}

In the code change the fields variable -> on the left side are the custom field keys, on the right side the placeholder for that field.