There are several ways to show a link to a post’s corresponding Mastodon status—an example of a so-called “syndication link”—on your site’s front end.
In a Classic Theme
Share on Mastodon stores Mastodon URLs in a _share_on_mastodon_url
custom field.
As a result, if you use a “classic” (i.e., mainly PHP-based) theme, you could modify “the loop,” and simply add something like …
<?php
// In one of your theme's templates, inside "the loop."
$mastodon_url = get_post_meta( get_the_ID(), '_share_on_mastodon_url', true );
if ( ! empty( $mastodon_url ) ) :
?>
<p>Also on: <a href="<?php echo esc_url( $mastodon_url ); ?>">Mastodon</a></p>
<?php
endif;
… pretty much anywhere you like.
Automatically Appended to a Post’s Content
Or you could use a the_content
filter, to append such a link to the post content:
<?php
// In your theme's `functions.php`, or a standalone "mu-plugin."
add_filter( 'the_content', function( $content ) {
if ( is_main_query() && in_the_loop() ) {
$mastodon_url = get_post_meta( get_the_ID(), '_share_on_mastodon_url', true );
if ( ! empty( $mastodon_url ) ) {
$content .= "\n<p>Also on: <a href=\"" . esc_url( $mastodon_url ) . '">Mastodon</a></p>';
}
}
return $content;
}, 99 );
Using the Syndication Links Plugin
If you’re already using the Syndication Links plugin, you can simply enable the “Syndication Links” setting under Share on Mastodon’s “advanced” settings!
In a Block Theme, Using the IndieBlocks Plugin
And if you happen to use the IndieBlocks plugin and have enabled its blocks option, you should have access to a “Syndication” block.
Use WordPress’ new Site Editor to add it to any theme template. (Much like the Post Title, Post Author, etc. blocks, the Syndication block is a “theme” block, and not so much meant to be inserted into posts directly.)
On this site, Mastodon (and Pixelfed) links, if they exist, are shown next to the tags, just below each post. For notes, they’re similarly positioned—a little lower, in fact, among a bunch of other metadata.