Skip to content

PHP Customization - how to shorten property title on the property cards (e.g. max 15 words)?

1 minute read

  1. 1 Find plugins/myhome-core/includes/estates/Estate.php
  2. 2 Backup the file
  3. 3 Find get_name function
php
public function get_name() {
   return $this->post->post_title;
}

4. Change it (15 is a limit of a words)

php
public function get_name() {
    $text = $this->post->post_title;
    $limit = 15;

       if (str_word_count($text, 0) > $limit) {
           $words = str_word_count($text, 2);
           $pos = array_keys($words);
           $text = substr($text, 0, $pos[$limit]) . '...';
       }
       return $text;
}

Ask the people who build MyHome WPBakery

We answer by email from support@tangiblewp.com. With Premium Support, we also fix your site when something breaks.

Was this guide helpful?