Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Edit custom field placeholder
This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko 1 year, 9 months ago.
- AuthorPosts
- June 8, 2021 at 5:12 pm #33562
Hi,
Where can I edit the custom field placeholder in the plugin?
I use text type.
Thanks.
Attachments:
You must be logged in to view attached files.June 9, 2021 at 8:46 am #33569Hi,
Well, unfortunately there is no option for that, but you can try a custom code for that.
Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.
add_action('wp_footer', 'wp_footer_change_filter_input_placeholder', 9999); function wp_footer_change_filter_input_placeholder() { ?> <script> (function(){ let text = "My placeholder text"; setTimeout(function() { document.querySelectorAll('fieldset.asp_custom_f input[type=text]').forEach(function(el){ el.placeholder = text; }) }, 100); }()) </script> <?php }
Change the
Best,text
variable in the code for the input text you want.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
June 10, 2021 at 12:34 pm #33599Thanks for your help.
If I have two text-type custom fields, the first one is “Name”, the second one is “Number”.
Could you tell me how to do this?
Thank you.June 10, 2021 at 3:23 pm #33606Might 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
Best,fields
variable -> on the left side are the custom field keys, on the right side the placeholder for that field.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.