Adams
September 5, 2022, 12:43am
1
Please update this snippet code to add %listing_title% and %listing_url% for users and show current classified listing title and url address in their wahtsapp messenger when click “Chat Via Whatsapp” and Show full Listing Title and full Referred URL of Listing for users and vendor
Like below:
Hello Vendor! I’m sending text for %listing_title% via %listing_url%
This is default snippet for sending Listing URL to WhatsApp chat and need update and adding %listing_title% to below codes, I’ve try but not working:
add_filter(
'hivepress/v1/models/listing/fields',
function( $fields, $listing ) {
foreach ( $fields as $name => $field ) {
if ( isset( $field['display_template'] ) && strpos( $field['display_template'], '%listing_url%' ) !== false ) {
$fields[ $name ]['display_template'] = str_replace( '%listing_url%', get_permalink( $listing->get_id() ), $field['display_template'] );
}
}
return $fields;
},
1000,
2
);
yevhen
September 5, 2022, 9:17am
2
Please try this PHP snippet
add_filter(
'hivepress/v1/models/listing/fields',
function( $fields, $listing ) {
foreach ( $fields as $name => $field ) {
if ( isset( $field['display_template'] ) ) {
$fields[ $name ]['display_template'] = str_replace( ['%listing_url%', '%listing_title%'], [get_permalink( $listing->get_id()), $listing->get_title()], $field['display_template']);
}
}
return $fields;
},
1000,
2
);
Adams
September 5, 2022, 10:41am
3
It’s not working yet. only showing listing url but listing title is not show!
yevhen
September 6, 2022, 8:21am
4
Please try this PHP snippet instead
add_filter(
'hivepress/v1/models/listing/fields',
function( $fields, $listing ) {
foreach ( $fields as $name => $field ) {
if ( isset( $field['display_template'] ) && (strpos($field['display_template'], '%listing_url%') !== false || strpos($field['display_template'], '%listing_title%') !== false) ) {
$listing_title = str_replace(' ', '+', get_the_title($listing->get_id()));
$fields[ $name ]['display_template'] = str_replace( ['%listing_url%', '%listing_title%'], [get_permalink( $listing->get_id()), $listing_title], $field['display_template']);
}
}
return $fields;
},
1000,
2
);
2 Likes
Adams
September 6, 2022, 4:02pm
5
Thanks, it’s now working great!
1 Like
system
Closed
October 6, 2022, 4:03pm
6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.