Join our new community forum for support & discussion
Join NowShare URL of listing
-
AuthorPosts
-
Aizen 3 years, 1 month ago
Hi Ihor,
Is it possible to create an button that can share a listing URL to an e-mail address? If so do you have any pointers on the best way of doing this? I’ve been trying to create it through a text attribute with HTML MailTo code without much success for some reason 🙁
Thanks,
A
sherwinramnarine 3 years, 1 month agoHi Aizen, I use Sumo on my directory (not on HivePress) that includes lots of sharing options for listings, including sharing by email. They offer a free version. Check them out > https://sumo.com/
Aizen 3 years, 1 month agoThanks, but that isn’t quite what I’m looking for. Sumo is all about getting subscribers, what I’m interested in doing is creating a button that shares the current page URL into an email.
Unfortunately this would require code customizations, currently only %value% and %label% tokens are available in the attribute format field.
Aizen 3 years, 1 month agoI would happily pay for this in code snippet form or whatever is easiest for you. Thanks
Thanks, you can help improve HivePress and speed up the development by donating any amount via PayPal. This code snippet adds %listing_url% token to the attribute display format:
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 );
So it’s possible to use it in the “mailto” link, for example by setting it as the email content https://stackoverflow.com/questions/4782068/can-i-set-subject-content-of-email-using-mailto
Aizen 3 years, 1 month agoThanks this is amazing, but when i attempt to add it to the functions.php it won’t let me save, it says “Something went wrong. Your change may not have been saved. Please try again. There is also a chance that you may need to manually fix and upload the file over http://FTP.”
Any idea?
Usually this error message is displayed when the theme files are not writable, so the built in WordPress code editor can’t change them https://wordpress.org/support/topic/error-message-something-went-wrong-your-change-may-not-have-been-saved-pleas/
Aizen 3 years, 1 month agoI can save other changes to it, but when I place that code it doesn’t work.
Aizen 3 years, 1 month agoI added the code via Cpanel, but wordpress comments it out in the admin dash, i think it’s an issue with the code – must be some kind of protection built into this new version of wpd?
It means that it’s added as an output outside of the PHP scope, please make sure that you add it to functions.php file, this file should start with
<?php
opening tag and it shouldn’t have the closing?>
tag, anything added after this closing tag will be output as text.Aizen 3 years, 1 month agoYes the functions.php file is what i have used, perhaps comment is the wrong word – when I add the code from cpanel it doesn’t show inside WP-admin even after refreshing / reloading the file. like the added code is invisible.
I tested this code snippet locally and it works for sure, please check that you add it to the current (preferably child theme) theme functions.php file, hope this helps https://createandcode.com/add-code-snippets-to-wordpress/
Aizen 3 years, 1 month agoAmazing thanks it has started working now – think it was a cache issue with my host.
unitehearts 2 years, 10 months agoI was looking for a way to get the Listing URL – happy to have found it. Thanks @Ihor
unitehearts 2 years, 10 months ago@Ihor – is there a way by which the Listing URL link can go in Whatsapp in such a way – that it will show a preview – as is often seen with URLs – with an image – or a small write up
This is related to Whatsapp, you can check if it fetches the image and short description when you send URL via the chat.
infoindustry 2 years, 10 months agoWhere should I add this code? To function.php of ListingHive theme?
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 );
infoindustry 2 years, 10 months agoI dont understand how to implement it, please explain
I added it into snippet but dont see itPlease don’t edit HivePress or ListingHive directly because any changes will be erased on the update. If you’re going to customize ListingHive a lot you can create a child theme https://wordpress.org/plugins/child-theme-generator/ and add custom snippets to the child theme functions.php file. If there will be only a few snippets you can just use this plugin https://wordpress.org/plugins/code-snippets/
-
AuthorPosts
New Reply
This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.