Use the filter comment_form_fields
instead of comment_form_defaults
. Also, in the call to str_replace()
, remove the =""
from required
in both strings. So, your code will become:
function custom_comment_form_placeholders( $fields ) {
if ( isset( $fields['comment'] ) ) {
$fields['comment'] = str_replace(
'<textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required></textarea>',
'<textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required placeholder="Write a Comment"></textarea>',
$fields['comment']
);
}
return $fields;
}
add_filter( 'comment_form_fields', 'custom_comment_form_placeholders' );
Related Posts:
- Am I using the right hook for removing quicktags on the admin TinyMCE?
- How do I target a single page to modify the comment form of only that page?
- How to modify core when there is no hook?
- Adding a filter to comments_template
- Use of comment_reply_link_args filter
- comment_for() Custom fields not visible when user is logged in
- Changing WooCommerce Display Price Based on User Role & Category [closed]
- How to add headers to outgoing email?
- LESS CSS enqueue_style with add_filter to change rel attribute
- Remove Editor From Homepage
- Remove description from on Home
- What do add_filters() and apply_filter() do?
- How can I detect if a user changes their password?
- Using filter to add additional fields to comment_form()
- What to use instead of the content_save_pre filter?
- Moving sharedaddy buttons (in Jetpack) to the top of a post?
- How can I customize the wp_list_categories
- changing variable through filters or action hooks
- filter the_title problem in nav
- Add classname to the_category() function?
- Filter the URL of next_posts_link & previous_posts_link
- How to replace any occurence of Gravatars with a local placeholder image?
- Sensei LMS Hooks to Remove Content
- How to re-enable a filter after disabling with __return_false
- Ignore dots when searching in the media library?
- Exclude One Category and its Subcategories using WP_LIST_FILTER
- Gutenberg disable the “block” tab in right sidebar
- Where is this inline CSS code [closed]
- When to use actions and when to use filters
- add_filter to ‘woocommerce_before_main_content’ [closed]
- Why won’t my preg_replace work with content_save_pre?
- Echoing Categories only if they’re a child of a given category
- How Does comment_author Filter Work?
- Add ‘data-text’ attribute to TagCloud HTML
- Why in archive page doesn´t show read more button with excerpt?
- Removal of Jetpack OG Tags from old blog site
- Walker_Nav_Menu doesn’t work in wp_page_menu_args filter
- get_posts() and filters
- Don’t see add_filter result in the site front page
- How can I include an existing custom sitemaps listing in wp-sitemap.xml?
- Display Externally Retrieved Data within a Custom Template
- Can the wordpress color palettes by changed through Javascript?
- Filter on the_content doesn’t update the content being searched via register_rest_route
- Where to add_filter in theme functions.php?
- upload_files cap to not loggen in users – add_cap to not logged in users
- Cannot change the definition of AUTOMATIC_UPDATER_DISABLED
- How do I add a checkmark to my-sites save settings hook
- tag removed not using a filter
- Add Lightbox To WordPress Native Gallery
- WordPress Image update filter
- How to remove this filter?
- get_post() containing gallery is outputting an unmatched closing div at the end of the content
- Trouble using remove_filter to override function in parent theme
- Load Posts’ individual body content on index starting at char 200 of each post
- How to combine multiple body classes
- Prepending character(s) to a custom tag title?
- How to replace username with email address in users table
- Modify existing plugin function with add_filter
- include specific Pages to wp_list_pages with filter
- why require – does not load filter
- How can I filter tag_description()?
- Email Obfuscation: Is antispambot() Acceptable? [closed]
- an action hook when a post reaches a certain number of views
- WordPress overwrites UNC
- Need to return shortcode text instead of the output
- Excluding posts by meta, and also keeping posts without the meta
- Change tags url to search different site
- How to optionally append components to the output of a gutenberg block?
- Dashboard filter based on custom fields URL response code
- Custom SQL query slows down when using multiple OR … LIKE … in posts_where filter
- I want to add string array to this function to filter displayed option in drpodown [closed]
- Drop down filter sort posts by latest, last 7 days and monthly
- Function not returning correct value for found_posts filter
- Unable to defer loading of jquery
- Remove style tags from head
- How to wrap pattern-matches from the_content in [wiki]-shortcode tags
- how to develop a filter in wordpress to let the user filter the page content depends on the date (newest to oldest etc…)?
- Print only parent categories of post in custom RSS feed
- Login logout below menu bar
- Use add_filter inside another function
- Add HTML to the bottom of each post in a post list
- Admin view: filter posts by whether they have specific taxonomy attached
- Filter posts by categories ajax is showing all the posts
- URL to filter posts by post meta similar to shop/?product_cat=”painting”
- Incrementing content with extra text after save/publish
- What scope is $blog_url = get_bloginfo() inside a function
- How to use a TinyMCE filter?
- Unable to get WordPress’s apply_filters(‘site_url’) to return a https scheme
- Admin filter/error if post title is too long
- How we make the filter for fornt end user
- What is the scope and persistence of add_filter() and remove_filter()?
- Filter dashboard custom post listing by user
- After adding filter to plugin’s code, post’s content doesn’t display
- if i put the code in my theme’s function.php file can it work?
- Admin New Order: Autofocus on Search a product
- How to filter part of a variable if it is no array?
- WordPress wp_lazy_loading_enabled returns loading attribute set to lazy
- Deregister Custom the_title Filter for edit_post_link
- How to apply_filter / add_filter within 2 others (simultaneous?) add_filter
- Deactivate code made with add_filter