WordPress and Mastodon Social Media Integration Updated on February 3, 2022 by InMotion Hosting Contributor 2 Minutes, 7 Seconds to Read The Mastodon social media platform is steadily gaining more popularity as Twitter and Facebook users tire of timelines manipulated for political purposes. For those who are part of the federating social network, there are plugins that allow you to automatically share new WordPress posts as toots (same as Twitter’s tweets). The Share on Mastodon WordPress plugin works without issue and is covered below. While the Mastodon Autopost plugin seems to be one of the most popular Mastodon server WordPress integrations, we couldn’t get it working with WordPress 5.8.2. Automatically Post to Mastodon Social Media Account Install and enable the “Share on Mastodon” WordPress plugin.In the WordPress dashboard under “Settings,” select “Share on Mastodon.”Type in your Mastodon instance URL.Check the “Post” checkbox.Save changes.Near the bottom select “Authorize Access.” Log into Mastodon, then select “Authorize” to allow WordPress to upload media files and posts as Mastodon toots.Create or edit a WordPress post.On the bottom of the post sidebar, you’ll see a “Share on Mastodon” section, with the feature enabled (checked) by default. Publish or update the post.The Mastodon section will now display a direct link to the toot. If you delete the linked toot at any point, you’ll need to unlink the old URL in WordPress to retoot the post. Though there aren’t additional features in the dashboard for the Mastodon integration (as of version 0.6.4), the plugin developer offers code snippets to further customize automated toots. To make adjustments, log into SSH (or cPanel Terminal) and navigate to your WordPress root directory. Now edit the plugin PHP file. nano wp-content/plugins/share-on-mastodon/share-on-mastodon.php To include WordPress post tags as hashtags in Mastodon toots for social media search engine optimization (SEO), add the following to the bottom of the PHP file: add_filter( 'share_on_mastodon_status', function( $status, $post ) { $tags = get_the_tags( $post->ID ); if ( $tags ) { $status .= "\n\n"; foreach ( $tags as $tag ) { $status .= '#' . preg_replace( '/\s/', '', $tag->name ) . ' '; } $status = trim( $status ); } return $status;}, 11, 2 ); To change a toot’s visibility from public to private, add the following: add_filter( 'share_on_mastodon_toot_args', function( $args ) { $args['visibility'] = 'private'; // Only followers will get to see this message. return $args;} ); Learn more about the auto-posting to the Mastodon social media network at https://github.com/janboddez/share-on-mastodon. For the most secure WordPress site, you need secure hosting. That’s why InMotion Hosting crafted WordPress Hosting with rigorous server-side security - so you can spend less time hardening your hosting and more time creating your website. WordPress Hosting Plans Share this Article InMotion Hosting Contributor Content Writer InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals! More Articles by InMotion Hosting Related Articles How to Backup WordPress with the BackWPup Plugin Learn How to Install and Use Mailchimp in WordPress How to Create and Manage 301 Redirects in WordPress How to Add PayPal to WordPress Website Using Video Conferencing with Zoom – WordPress Plugin Create a WordPress News Website with the WP News and Scrolling Widgets plugin Getting Started: Constant Contact Plugin for WordPress The Yoast SEO Plugin: Optimize Your Website to Boost Traffic GiveWP Donation WordPress Plugin Learn WPForms WordPress Plugin: An Overview and Guide