Skip Navigation

[Resolved] Share links to posts but substitute the domain.

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to create a link to share my post. The link should act like a "mailto" link, opening the email editor with some prepopulated information about the post in the mail body.

Solution: You can add parameters and shortcodes to the mailto link URL to set any HTML you want in the message. Designing that template will require custom HTML and CSS.

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-type
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-slug
https://css-tricks.com/snippets/html/mailto-links/

This support ticket is created 5 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 11 replies, has 3 voices.

Last updated by larryL 5 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#1183013

I want to create share links for posts but change the domain in those links from domaina.com/post1 to domainb.com/post1

How can I do that?

#1183136

Hi, there's nothing built in to Toolset that will automatically filter link URLs like this. Depending on the URL structure and post type, you might be able to create links manually with HTML and Views shortcodes, like this:

<a href="<em><u>hidden link</u></em>;">Share [wpv-post-title]</a>

https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-type
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-slug

#1186217

Actually Christian that totally worked!! I massaged it a little to remove the post-type in the URL but otherwise, fantastic!.

Now, if I wanted to turn this into an actual 'share' type function - how would I make this mainto:... Also, can I put this behind an image instead of displaying the name of the post?

Thanks!

#1186225

Now, if I wanted to turn this into an actual 'share' type function - how would I make this mainto:...
You want to create a mailto link that puts the destination URL in the message of an email, if I understand you correctly. You can do that by appending the "message" URL parameter to the email address, like this:

<a href="mailto:someone@something.com?message=Check out this post: [wpv-post-url]">[wpv-post-title]</a>

https://css-tricks.com/snippets/html/mailto-links/

Also, can I put this behind an image instead of displaying the name of the post?
Yes, you can replace the text inside the link tag with an image tag, something like this:

<a href="mailto:someone@something.com?message=Check out this post: [wpv-post-url]"><img src="<em><u>hidden link</u></em>" alt="[wpv-post-title]" /></a>

https://www.w3schools.com/html/html_images.asp

#1187429

Here is what I was trying to do:

<a href="mailto:?message=[wpv-post-title]hidden link;"><img src="/wp-content/uploads/2019/01/share-email.png" width="30" height="30" align="center">

But it doesn't work.

#1187705

Ah, sorry it's actually "body" not "message". Here's an updated snippet:

<a href="mailto:?body=[wpv-post-title]<em><u>hidden link</u></em>;"><img src="<em><u>hidden link</u></em>" width="30" height="30" align="center"></a>

The image you were using doesn't exist, so I substituted a different image.

#1187780

So, the body is filled out althought it just repeats the title with a link inbetween <u> tags.

It also is missing a subject line.

#1188325

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Larry,

Christian is currently not available today but will be back tomorrow to continue with you.

Thanks,
Shane

#1189137

So, the body is filled out althought it just repeats the title with a link...
Yes, that makes sense based on what your message was set to be:

[wpv-post-title]<em><u>hidden link</u></em>;

What exactly do you want to be inserted in the body of the email?

It also is missing a subject line.
Add the parameter "subject" to the mailto link URL to include a subject line. There is an example here: https://css-tricks.com/snippets/html/mailto-links/

#1189210

I guess I hadn't thought that through 🙂

I suppose I would prefer to provide a more formated message with the contents for some custom fields. Am I getting into an area that is beyond the scope of Views?

#1189291

You're getting into an area that requires some advanced knowledge of HTML and CSS, because Views isn't designed for visually formatting HTML emails. That's tricky business, even for experienced developers, because different email systems have different rendering engines that interpret CSS slightly differently. Views shortcodes can be placed in the mailto URL message parameter, so in theory you could use a WYSIWYG field to build an HTML email message. Then insert the WYSIWYG field in the message parameter of the mailto attribute. However, the overall display of the email is completely based on your own custom HTML and styles.

#1193302

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.