Specific Post Category Sharing to Mastodon from WordPress

I added this snippet which seemed to do the trick of only sharing WordPress posts categorized as “Status” up to Mastodon. The rest I’ll share manually

/**
 * Enable sharing only for posts in the "Status" category.
 *
 * @param bool $is_enabled Whether the post is enabled for sharing.
 * @param int  $post_id    The ID of the post being processed.
 * @return bool Updated sharing eligibility.
 */
function enable_sharing_for_status_category( $is_enabled, $post_id ) {
    // Ensure this is a valid post ID
    if ( ! $post_id ) {
        return false;
    }

    // Check if the post belongs to the "Status" category
    if ( has_category( 'Status', $post_id ) ) {
        return true; // Allow sharing
    }

    return false; // Block sharing
}
add_filter( 'share_on_mastodon_enabled', 'enable_sharing_for_status_category', 10, 2 );

Posted

in

,

Current Spins

Top Albums

Check out my album Set It All Down on your favorite streaming service.


Posts Worth Reading:


Letterboxd


Reading Notes

  • Who profits from our constant state of dissatisfaction? The answer, of course, is painfully obvious. Every industry that sells a solution to a problem you […]
  • the shifts have been in place for awhile. A certain kind of book—say those reviewed in the NYRB—will become like opera, or theater, or ballet, […]
  • • No more struggle: “Whatever arises, train again and again in seeing it for what it is. The innermost essence of mind is without bias. […]
  • The real problem, in my mind, isn’t in the nature of this particular Venture-Capital operation. Because the whole raison-d’etre of Venture Capital is to make […]
  • . The EU invokes a mechanism called the precautionary principle in cases where an innovation, such as GMOs, has not yet been sufficiently researched for […]

Saved Links