WordPress Functions

How to Make Jetpack Stop Sharing Blog Posts

One of the great features Jetpack offers is its newsletter. With Jetpack Publicize on, our posts are automatically sent to our email subscribers and displayed at the WordPress Reader. But what if need Jetpack to stop sharing some of our posts?

jetpack stop sharing posts

My scenario: Importing Posts From Another Blog

I had my blog on Maintenance Mode (with the plugin by SeedProd), and I was importing old posts from a WordPress.com blog. Soon I noticed that Jetpack was sharing them as if they had been just published, when they were already public and from 2016.

In case you are wondering: if you set a blog post to “private”, to edit it for instance, the moment you switch it back to “public” Jetpack will share it again at the WordPress Reader.

For any reason, if you’d like to exclude some of your posts from the newsletter and the WordPress reader, there is a very simply filter to make jetpack stop sharing posts from certain categories.

Requirements: You’ll be modifying your theme’s files, which is strongly discouraged. For this reason, we create “Child Themes”, something you can achieve very easily in a couple of minutes. Check out how to create a child theme at my toolkit, step by step.

How to Make Jetpack Stop Sharing Blog Posts: Step By Step

This filter is provided by Jetpack and it works to exclude categories. Hence the first step is to choose a category or create a new one, and then assign it to the posts you don’t want to share.

Finally, in your functions.php file, write the following:

// Jetpack sharing
// https://developer.jetpack.com/hooks/jetpack_subscriptions_exclude_these_categories/
function jetpackme_exclude_posts_subscriptions( $categories ) {
$categories = array( 'yourcategory');
return $categories;
}
add_filter( 'jetpack_subscriptions_exclude_these_categories', 'jetpackme_exclude_posts_subscriptions' );

A couple of notes on the filter:

  1. You only need to replace yourcategory with, well, the slug of your category.
  2. I always use notes in my functions, to recall what is for (// Jetpack Sharing) and the URL where I found the snippet; which, as you can see, it’s at developer.jetpack.com (from the source!)

More Resources

Whenever you need to do something else, go straight to the source. Jetpack, as well as WordPress and plugins, may have the solution you’re looking for at a couple of clicks away.

At Developer / Jetpack you’ll find a search bar, and a sidebar with a list of features. The one we used today is under the module Subscriptions.

At Developer / WordPress, you’ll find a search bar and the option to filter your search by type (functions, hooks, classes and methods). Or if you prefer to look at all of them at once, at WordPress Codex there is the original list of functions.

Laly York. Neurodivergent Gen-X writer / B.Ed. / Lawyer. Writing, coding and taking pics. From Jupiter, living in a soap opera; flying on the web with three blogs.

JOIN COMMENTS

Any thoughts?

Discover more from Laly

Subscribe now to keep reading and get access to the full archive.

Continue reading