Jetpack: remove a post from the Top Posts Widget

If you use the Jetpack plugin, you’re probably familiar with the Stats module. Once you’ve activated the module, you can also use the Top Posts widget to display a list of the most popular posts on your site.

But what if there is one post that you never want to display there, even if it’s a popular one? You can exclude specific posts from the widget thanks to the jetpack_widget_get_top_posts filter.

To do so, paste the following code into a functionality plugin:

function jeherve_remove_post_top_posts( $posts, $post_ids, $count ) {
	foreach ( $posts as $k => $post ) {
		// Replace 1215 by the ID of the Post you want to remove
		if ( '1215' == $post['post_id'] ) {
			unset( $posts[$k] );
		}
	}
	return $posts;
}
add_filter( 'jetpack_widget_get_top_posts', 'jeherve_remove_post_top_posts', 10, 3 );

Get a headstart with install.php & Jetpack – Timișoara WordPress Meetup

I was invited to Timișoara to give a talk about Jetpack, and got to meet with the local WordPress community. It was a great meetup. Kudos to the folks from Presslabs, Rainfall, Cosmoslabs, and Get Bowtied. Thanks for being so welcoming. I’ll come again!

I chose to talk about install.php, and how you could use it alongside mu-plugins and functionality plugins to speed things up when installing new WordPress sites. Here are my slides:

Get a headstart with install.php & Jetpack

You can also check the slides on GitHub.

Here is the full install.php I created for the purpose of this talk. Credit goes to Mike Schinkel and Kathy for a big part of the functions in there.

If you have questions about some of the Jetpack filters used in the talk, or if you would like to see more filters added to Jetpack, do not hesitate to join us on GitHub!

Blast off with Jetpack – WPBudapest meetup

Last night, I gave a talk about Jetpack at our local #WPBudapest meetup. If you live in Budapest and like WordPress, you should join us next time!

And until next month, you can check my slides here:

Blast off with Jetpack

Discover the Jetpack plugin, and why should you give it a try on your WordPress site.

If you have any questions about my presentation, let me know!

Jetpack: add hashtags to the twitter sharing button

A few days ago I explained how to add hashtags to the tweets sent out by Jetpack Publicize. But what about the tweets your read can send using the Jetpack Sharing buttons at the bottom of your posts?

Here is how to get tags from your posts, and add them as hashtags to the twitter sharing button. As always, you’ll want to paste that code in a functionality plugin.

function jeherve_custom_sharing_title() {
        $post = get_post();
        if ( empty( $post ) ) {
                return;
        } else {
                // Create sharing title
                $sharing_title = get_the_title( $post->ID );

                // Get the tags
                $post_tags = get_the_tags( $post->ID );
                if ( ! empty( $post_tags ) ) {
                        // Create list of tags with hashtags in front of them
                        $hash_tags = '';
                        foreach( $post_tags as $tag ) {
                                $hash_tags .= ' #' . $tag->name;
                        }
                        // Add tags to the title
                        $sharing_title .= $hash_tags;
                }

                return $sharing_title;
        }
}
add_filter( 'sharing_title', 'jeherve_custom_sharing_title', 10, 3 );

Hat tip to Ryan for the idea!

Jetpack: add hashtags to tweets sent by Publicize

Jetpack’s Publicize module allows you to automatically publish your posts to your favorite Social Networks like Twitter or Facebook.

You can customize the message that is posted to Social Networks thanks to the small input field right above the Publish button:

Publicize Options

But what if you wanted to automatically add details to each Publicized post? Since both Twitter and Facebook support hashtags, you could append the post tags after the post title, like so:

Tweet tags

To do so, add the following code to a functionality plugin:

function jeherve_publicize_hashtags() {
	$post = get_post();
	if ( ! empty( $post ) ) {

		// Grab the tags of the post
		$post_tags = get_the_tags( $post->ID );

		// Append tags to custom message
		if ( ! empty( $post_tags ) ) {

			// Create list of tags with hashtags in front of them
			$hash_tags = '';
			foreach( $post_tags as $tag ) {
				$hash_tags .= ' #' . $tag->name;
			}

			// Create our custom message
			$custom_message = get_the_title() . ' ' . $hash_tags;
			update_post_meta( $post->ID, '_wpas_mess', $custom_message );
		}
	}
}

// Save that message
function jeherve_cust_pub_message_save() {
	add_action( 'save_post', 'jeherve_publicize_hashtags' );
}
add_action( 'publish_post', 'jeherve_cust_pub_message_save' );

A Day in the life of a Happiness Engineer

All the cool kids are doing it, so I guess I should too! These past few days, a few Happiness Engineers have been writing about what we do on a daily basis at Automattic. If you’re interested in reading more you can follow the tag #a8cday.

Although I don’t really have a typical day, here is a small preview of what I do at work.

Continue reading A Day in the life of a Happiness Engineer