What’s the best way to set the required atribute on html forms in wordpress, for instance I would like post-content to be required, so this code need to be changed:

<textarea class="wp-editor-area" style="height: 300px; margin-top: 37px;" autocomplete="off" cols="40" name="content" id="content"></textarea>

To appear like this:

<textarea required class="wp-editor-area" style="height: 300px; margin-top: 37px;" autocomplete="off" cols="40" name="content" id="content"></textarea>

How can do it by a hook filter?
This same solution I will also use it for other fields in the publish post form

Read more here: Make post_content and other custom fields required


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: