Share URL of listing

  • Author
  • Aizen

    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 🙁




    Hi 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 >


    Thanks, 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.

    ihor developer

    Unfortunately this would require code customizations, currently only %value% and %label% tokens are available in the attribute format field.


    I would happily pay for this in code snippet form or whatever is easiest for you. Thanks

    ihor developer

    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:

    	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;

    So it’s possible to use it in the “mailto” link, for example by setting it as the email content


    Thanks 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?

    ihor developer

    Usually this error message is displayed when the theme files are not writable, so the built in WordPress code editor can’t change them


    I can save other changes to it, but when I place that code it doesn’t work.


    I 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?

    ihor developer

    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.


    Yes 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.

    ihor developer

    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


    Amazing thanks it has started working now – think it was a cache issue with my host.


    I was looking for a way to get the Listing URL – happy to have found it. Thanks @Ihor

Viewing 15 posts - 1 through 15 (of 20 total)

You must be logged in to reply to this topic.


Sign In

Don't have an account? Register

Forgot password?


Already have an account? Sign In

Forgot password?

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.