Ever since I migrated off micro.blog, I have been trying to replicate a few workflows that worked extremely well for me. My basic requirements were:
1: Ability to use *this* blog as the source of truth of anything I post and act as a cross-poster.
2: Ability to not have a link back to this blog if my post was a "micro", i.e something that fits within the character limits of mastodon/bluesky so it appears as if I posted there by default.
Getting here as been challenging, and while I have most of the pieces figured out, there are still some quirks and annoyances that I dont think I can invest time into fixing (not right now anyways!), so I will live with it. Here is how I achieved the outcomes.
I have blogged a little bit my journey out of micro blog so far. This is a wordpress hosted blog on pikapods. PikaPods abstracts away management of servers and gives me a wordpress stack ready to play around with. While this is great, it also limits my ability to touch the core wordpress files because I do not have any access to the actual box hosting this wordpress instance. This can be a boon in cases where you have no desire to muck around the files, but can be challenging in situations where you do want to muck around with no access to the underlying instance hosting the blog.
Luckily, enter WPCode, a code snippets plugin that allows you to inject pieces of code all across your WordPress instance without you having to access the underlying files. There are many code snippets plugins out there, but this one worked best for me. I did not need anything more than the free version to do what I wanted to achieve out of this. Code snippets can be of any type – Javascript, PHP, CSS or the likes. WPCode also comes handy with many out of box snippets that you can use right away.
I also bought a subscription to echofeed app that makes cross posting to mastodon/bluesky easier, but its a clunky service that acts up from time to time. However using echofee made my second requirement easier about not having a link-back to the blog for a true micro post. I currently have 4 different Echofeeds setup to do the following:
1: Cross post a "micro" post to Mastodon/Bluesky without a link-back to this blog.
2: Cross post a non-micro post to Mastodon/Bluesky WITH a link-back to this blog.
To achieve this, the approach I took was to use a category feed for wordpress. WordPress has a general all purpose feed at the blog level, but you also can reach individual category feeds. For my purpose, I needed these feeds:
stupendous.blog/feed -- The general all-encompassing feed.
stupendous.blog/category/micro/feed -- the actual "micro" posts feed that don't need a link-back.
The first part was easy, I could use my category feed as a separate source in echofeed to cross-post to Mastodon/Bluesky. All I had to do was ensure that I just used {{ content:plain }}
in my content tag. All my micro posts are now posted Mastodon/Bluesky with no link-back. I also had another Echofeed that took in the overall feed as well with {{ content:plain }} {{ link }} that allowed a link-back to be posted on Bluesky/Mastodon.
This had problems. First, because I used both a general purpose feed and a category feed, my micro posts were also a part of general feed. It makes sense – it is the overall encompassing feed. And second, because of that I would now have multiple posts on Mastodon/BlueSky, one with link-back and one without. So i needed a solution that worked for both.
Enter code snippets! I needed my general feed to NOT show any micro posts, but show posts in every other category. Luckily there was already a code snippet that did this job in kinda similar way. I had to edit the file to suit my purposes, but the PHP snippet that I configured via WPCode to run anywhere was this:
add_action('pre_get_posts', 'exclude_category' );
function exclude_category( &$wp_query ) {
// Exclude from loop, archive and feed but not from category page/feed
if( ( is_feed() && !is_category() ) || ( is_archive() && !is_category() )) { // Exclude from feed, but not from category page/feed
set_query_var('category__not_in', array(1)); // Exclude category with ID 1
}
}
The above code excludes my micro posts from being included in the general feed, but not from a category feed. I had to find the exact numerical value of my category, but it was easy with some googling on how to. With the above code snippet enabled, my general feed stupendous.blog/feed
does not have any micro posts in them. This is exactly what I needed! Using the two feeds one for general without micro posts, and one specific to micro posts I was able to configure Echofeeds that cross-posted micro posts without link backs and macro posts with link backs.
But then, how do I know which post is a micro and which post is not? I generally do not pay attention to word or character count. Sure I could judge manually and assign a category to my post so the right feed had it, but that felt like too much work. Plus I also post through mobile apps so i was not sure how that would work out. I needed an automated solution that looked at number of characters in my post and assign a category to the post automatically. It felt fairly obvious – if a post was > 280 characters (for Masto instance i am on), then assign “Macro” category, and if not, keep it micro.
To solve for automatic categorization of posts, I used another PHP code snippet. My initial script was:
/**
* Prevent publishing posts under a minimum number of words.
*
* @param int $post_id The id of the post.
* @param WP_Post $post The post object.
*
* @return void
*/
function wpcode_snippet_publish_min_words( $post_id, $post ) {
// Edit the line below to set the desired minimum number of words.
$word_count = 299;
$content = $post->post_content;
$char_count = strlen($content);
$defaultCat = get_cat_ID( "Macro" ); //Get ID of "Macro" category
global $post;
if ( $char_count > $word_count ) {
wp_set_post_categories( $post_id, $defaultCat );
}
}
//add_action( 'publish_post', 'wpcode_snippet_publish_min_words', 9, 2 );
add_action( 'edit_post', 'wpcode_snippet_publish_min_words', 9, 2 );
This did the job! I was ecstatic as any time I posted a post, on publish it checked against number of characters and categorized post as Macro or micro. However there was one problem – this did NOT work when I used the WordPress or Jetpack app to post. After digging around this weekend, I came to understand that I had to replace
add_action( 'publish_post', 'wpcode_snippet_publish_min_words', 9, 2 ); [hence its commented out above]
with
add_action( 'edit_post', 'wpcode_snippet_publish_min_words', 9, 2 );
After reading a bit, I discovered that I needed an action to trigger once a post had been published not before. While the publish_post
would work if I had access to underlying instance and I could modify the files there, what I needed was this action to work after the post was published. Hence edit_post
action works better rather than publish_post. Changing this made all the difference – now no matter which device I used, a post was categorized as micro or macro without fail.
So, this is where I am now: 1/Whenever I post something the script above automatically tags a post as macro or micro based on # of characters, 2/I have another script that excludes micro posts from showing up in general feed and 3/I have multiple echofeeds to cross post macro and micro posts knowing that posts won’t be replicated. This has been working fairly well with a few quirks: 1/Sharing an image or link via share action on IOS app does not trigger this action. I couldnt care about this as I dont do that enough. 2/Echofeed still shows duplicate posts for micro post and I have no idea how to fix it – I think this is a Echofeed problem.
The other big caveat being, i am NOT a programmer! All of this was through google search, stackexchange and chatGPT. I know enough to understand code and make changes to suit me, but my capabilities end right there. I am 100% sure there are much optimal ways to do what I want, but this works for me right and works well. If you have any optimizations I can do, please let me know and I will try it!