WordCamp in Athens

I bought a ticket for WordCamp Europe 2023 in Athens! After missing last year’s #wceu, I am looking forward to exploring a city I have never been to and meeting many of the people I haven’t seen since 2019!

Exclude Status Posts From RSS Feed in WordPress

I added a notes feature to my blog using WordPress’ status post format.

At some point I might create a separate RSS feed for those posts, but for now I wanted to exclude them from the general RSS feed, to keep it somewhat clean, containing only proper blog posts.

This is how I implemented it:

function my_theme_exclude_status_posts_from_feed( $wp_query ) {
	if ( $wp_query->is_feed ) {
		$status_posts = get_posts( [
			'posts_per_page' => -1,
			'tax_query' => [
				[
					'taxonomy' => 'post_format',
					'terms' => [ 'post-format-status' ],
					'field' => 'slug',
					'operator' => 'IN',
				]
			],
			'fields' => 'ids'
		] );

		$wp_query->set( 'post__not_in', $status_posts );
	}

	return $wp_query;
}

add_filter( 'pre_get_posts', 'my_theme_exclude_status_posts_from_feed' );

Please let me know, if you know of a better/cleaner way to achieve this.


Update: After some input from Mark, I rewrote it, with one query less:

function my_theme_exclude_status_posts_from_feed( $wp_query ) {
	if ( $wp_query->is_feed ) {

		$filter = [
			'taxonomy' => 'post_format',
			'terms' => [ 'post-format-status' ],
			'field' => 'slug',
			'operator' => 'NOT IN',
		];

		$tax_query = $wp_query->get( 'tax_query' );

		if ( is_array( $tax_query ) ) {
			$tax_query[] = $filter;
		}
		else {
			$tax_query = [ $filter ];
		}
		
		$wp_query->set( 'tax_query', $tax_query );
	}

	return $wp_query;
}

add_filter( 'pre_get_posts', 'my_theme_exclude_status_posts_from_feed' );

Automatically Share WordPress Posts on Mastodon

Since Mastodon is really taking off (this time around), I was thinking about how to use it and integrate it into my general publishing workflow. (Not that I am posting much, but still.)

I have always been a fan of posting to my blog first, then to social media second.

A couple of days ago I activated post formats, more precisely the “status” format, to publish short notes, which do not warrant a proper blog post.

I also wanted to share those notes on Mastodon automatically. When looking into how to achieve that, I found the Share on Mastodon plugin. It is pretty straight forward to configure and it just works.

Jan, the developer, has added some well placed filters, which you can use to define exactly what is being shared. Have a look at the documentation with some examples on Jan’s website.

I made some adjustments using the share_on_mastodon_status filter, so that the post on Mastodon contains different things depending on the post format:

add_filter( 'share_on_mastodon_status', function( $status, $post ) {

    // Share only the post content if it is a status post
    if ( has_post_format( 'status', $post ) ) {
        $status = wp_strip_all_tags( $post->post_content );
    }
    // Share title + tags + url, if it is a regular post
    else {
        $status = wp_strip_all_tags( get_the_title( $post->ID ) );
        $tags = get_the_tags( $post->ID );
        if ( $tags ) {
            $temp = '';
            foreach ( $tags as $tag ) {
                $temp .= '#' . preg_replace( '/\s/', '', $tag->name ) . ' ';
            }
            $status .= "\n\n" . trim( $temp );
	}
        $status .= . "\n\n🔗 " . get_the_permalink( $post->ID );
    }

    return $status;

}, 10, 2 );

Let’s connect on Mastodon!

Create a Custom Settings Page in WordPress

I have created a lot of custom settings pages in WordPress over the years. Still, this morning, I struggled, because my options just wouldn’t save. So I decided to write down all the parts as a very basic reference for my future self.

Read more

picu Update

We just released picu 1.6.0, which adds support for multi-client collections. This was by far the most involved project inside of picu to date, as it required us to touch almost all parts of the plugin.

Read more

I replaced WordPress with Kirby

For a couple of months now my photo blog has been running on Kirby. In the following post I will share some observations I made during the implementation of my first real life project using Kirby, in which I re-built my photo blog, which was previously running on a completely custom built WordPress theme.

Read more

This is my photographic recap of WordCamp Europe #6, which took place in Belgrade, Serbia last week.

Read more

The fifth WordCamp Europe took place in Paris last week. I am repeating myself each year, when I say how great it was!

I had the role of photography team lead this year, which meant that I somehow ended up shooting fewer images than in the years before. Nevertheless – here are my favorite photos (that I took) from WordCamp Europe 2017.

Read more

Once again an amazing WordCamp Europe lies behind us. This time the WordPress community met in Vienna, Austria.

As in the previous three years, here are a few of my favorite images.

Read more

picu at #wcch

Our WordPress Plugin picu is almost ready to be released.

We are now a micro sponsor for WordCamp Switzerland. So if you are a photographer and are interested in WordPress come and talk to us at #wcch.

#wcch

Tickets are cheap, get yours now.