PHP Customization - how to limit property card address length (e.g. max 9 words)?
1 minute read
- 1 Find plugins/myhome-core/includes/estates/Estate.php
- 2 Backup the file
- 3 Find get_name function
php
public function get_address() {
if ( ! empty( \MyHomeCore\My_Home_Core()->settings->props['mh-estate_hide-address'] ) ) {
return '';
}
$location = $this->get_location();
return empty( $location['address'] ) ? '' : $location['address'];
}
4. Change it (9 is a limit of a words)
php
public function get_address() {
if ( ! empty( \MyHomeCore\My_Home_Core()->settings->props['mh-estate_hide-address'] ) ) {
return '';
}
$location = $this->get_location();
$text = $location['address'];
$limit = 9;
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.
We can also run your site for you, or build a new one.
Was this guide helpful?