janboddez / share-on-mastodon

Easily share WordPress posts on Mastodon.
https://jan.boddez.net/wordpress/share-on-mastodon
GNU General Public License v3.0
39 stars 5 forks source link

Any way to grab the shared status's URl? #85

Closed edent closed 11 months ago

edent commented 11 months ago

Enhancement idea.

At the bottom of my post, I'd like a link which says "Discuss this post on Mastodon" with a link to the status sent by this plugin.

I know I could manually grab the URl after it has been published, and then edit my post. But I wondered if that could be automated?

Is that sort of thing possible? Or is it a daft idea?

janboddez commented 11 months ago

Not daft at all, been doing this for years and recently wrote this about it: https://jan.boddez.net/articles/displaying-share-on-mastodon-links-on-wordpress-front-end. (The custom field has always been mentioned in the docs, too, but without actual examples of how to use it.)

If you're on a theme that you control, I'd go for the first approach but maybe wrap the example code in a "template tag" function which can then be inserted wherever you need it. Otherwise, the "post-content" hook should do the trick. Just adapt the text to whatever you want it to be.

If you crosspost to multiple platforms, the Syndication Links plugin might be worth a look. I believe it basically takes the second approach. To get the Mastodon links in there, there's a setting somewhere (Share on Mastodon > Settings > Advanced) that'll only show if both plugins are active.

Case anyone who reads this would prefer a block-based approach, the IndieBlocks plugin comes with a Syndication block that can be added, using the new site editor, pretty much anywhere.

edent commented 11 months ago

Ah! That's perfect. I've stuck it I'm my comment walker and it is now appearing as a native comment.

Ta!