---
title: "WordPress and Mastodon Social Media Integration"
description: "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..."
url: https://www.inmotionhosting.com/support/edu/wordpress/plugins/autopost-mastodon-social-media/
date: 2021-11-10
modified: 2022-02-03
author: "InMotion Hosting Contributor"
categories: ["WordPress Plugins"]
type: post
lang: en
---

# WordPress and Mastodon Social Media Integration

![Share on Mastodon WordPress Plugin - Autopost to Mastodon](https://www.inmotionhosting.com/support/wp-content/uploads/2021/11/share-on-mastodon-1024x538.jpg)

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**](https://wordpress.org/plugins/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

1. Install and enable the “Share on Mastodon” WordPress plugin.
2. In the WordPress dashboard under “Settings,” select “Share on Mastodon.”
3. Type in your Mastodon instance URL.![Share on Mastodon plugin settings](https://www.inmotionhosting.com/support/wp-content/uploads/2021/11/share-on-mastodon-settings-1024x548.png)
4. Check the “Post” checkbox.
5. Save changes.
6. Near the bottom select “Authorize Access.” 
7. Log into Mastodon, then select “Authorize” to allow WordPress to upload media files and posts as Mastodon toots.![Authorize WordPress and Mastodon social media account integration](https://www.inmotionhosting.com/support/wp-content/uploads/2021/11/share-on-mastodon-authorize.png)
8. Create or edit a WordPress post.
9. On the bottom of the post sidebar, you’ll see a “Share on Mastodon” section, with the feature enabled (checked) by default. ![Post will be tooted once published or updated](https://www.inmotionhosting.com/support/wp-content/uploads/2021/11/share-on-mastodon-post-options.png)Publish or update the post.
10. The Mastodon section will now display a direct link to the toot. ![Post shared on Mastodon and direct link](https://www.inmotionhosting.com/support/wp-content/uploads/2021/11/share-on-mastodon-post-linked.png)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](https://www.inmotionhosting.com/support/server/ssh/how-to-login-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](https://www.inmotionhosting.com/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](https://www.inmotionhosting.com/wordpress-hosting)
