Hi,
we do not have functionality that would limit the description by the number of words, but you can add the code below in your theme functions.php file it will add it
class Ad_Description_Word_Limiter {
public function __construct() {
add_action( "init", [$this, "init"] );
add_filter( "adverts_form_load", [$this, "form_load"] );
}
public function init() {
if( ! defined( "ADVERTS_PATH" ) ) {
return;
}
adverts_form_add_validator("my_word_limiter", array(
"callback" => [$this, "validate"],
"label" => "Word Limiter",
"params" => array( "max" => 10 ),
"default_error" => __( "Your description has too many words. Max %max% words.", "wpadverts" ),
"validate_empty" => false
));
}
public function validate( $data, $params ) {
$text = strip_tags( $data );
$word_count = str_word_count( $text );
$max_words = absint( $params["max"] );
if( $word_count > $max_words ) {
return "invalid";
}
return true;
}
public function form_load( $form ) {
if( $form["name"] != "advert" ) {
return $form;
}
foreach( $form["field"] as $k => $f ) {
if( $f["name"] == "post_content" ) {
$form["field"][$k]["validator"][] = [
"name" => "my_word_limiter",
"params" => [ "max" => 5 ]
];
}
}
return $form;
}
}
$Ad_Description_Word_Limiter = new Ad_Description_Word_Limiter();
In the code look for [ "max" => 5 ]
this limits the max words number to 5 if you want to allow more words increase the number.