Setting Maximum length for question title and question content

2.40K viewsIssueslength limit limit-tags question title
0

Hello,
I found this old question that was answered, and mentions it was already solved: https://anspress.net/questions/question/how-to-set-maximum-length-of-a-question-title/
But when I look at the AnsPress Settings, there’s only an option for:

  • Minimum title length
  • Minimum question content

There’s no option for Maximum length title or question content.
How can I set the limits for this?
Thank you.

Question is closed for new answers.
Marked as closed
0

Hello, there is already 100 max length validation on title. You can override that using below code.

<?php
/**
 * Override post_title max length validation.
 *
 * @param array $form Form arguments.
 * @return void
 */
function my_custom_question_field( $form ) {
  // Url field.
  $form['fields']['post_title'] = array(
    'max_length' => 100,
    // 'validate'   => 'required,min_string_length,max_string_length,badwords',
  );
   return $form;
}
 add_filter( 'ap_question_form_fields', 'my_custom_question_field' );

Posted new comment

Thanks Rahul, I didn’t know there was a 100 character max limit, that’s great. Is there any max character limit for the ‘question content’ or a snippet like this I could use to set it?

Thank you.