Closed ericdano closed 1 year ago
If you're familiar with customizing WordPress (as in, adding custom PHP snippets to either a must-use plugin or your [child] theme's functions.php
), you could try something like this:
add_filter( 'share_on_mastodon_status', function( $status, $post ) {
$tags = get_the_tags( $post->ID );
if ( $tags && ! is_wp_error( $tags ) ) {
$status .= "\n\n";
foreach ( $tags as $tag ) {
$tag_name = $tag->name;
if ( preg_match( '/\s+/', $tag_name ) ) {
// Try to CamelCase multi-word tags.
$tag_name = preg_replace( '/\s+/', ' ', $tag_name );
$tag_name = explode( ' ', $tag_name );
$tag_name = implode( '', array_map( 'ucfirst', $tag_name ) );
}
$status .= '#' . $tag_name . ' ';
}
$status = trim( $status );
}
return $status;
}, 11, 2 );
Also discussed here: https://jan.boddez.net/wordpress/share-on-mastodon#share_on_mastodon_status
I'm considering adding a bunch of options in a next version, I may take this one along.
It would be great if Tags in Wordpress translated to Hashtags in Mastodon.