Prevent Multiple Contact Form 7 Submissions without JavaScript

If you want to stop users from clicking the submit button on Contact Form 7 forms multiple times, eg. to prevent multiple submissions, add this CSS snippet to your stylesheet:

.wpcf7-form.submitting .wpcf7-submit {
    pointer-events: none;
}

Explanation:

  • CF7 will add the submitting class, once the submit button has been clicked. The class will persist until all fields have been validated and/or the form has been sent successfully.
  • The pointer-events property with a value of none will make the submit button not clickable.

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

Creating a Photo Archive Website From My flickr Data

I am not sure when I finally canceled my flickr Pro account. I always liked flickr for what it was, but for the last couple of years I have only ever used it to upload photographs for events I documented. I was thinking about deleting my account, but it has grown to a substantial archive with loads of images, and it felt wrong to just delete them. I definitely wanted an archive for my self so I requested my data from flickr.

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

Webbed Briefs

I recently stumbled upon the video series called Webbed Briefs by Heydon Pickering.

They are very well made and really funny. Four episodes exist at the time of me writing this. Do yourself a favour and watch all of them.

(And because Heydon uses a very similar style of presenting live, it also reminded me how much I miss documenting events with my camera. Here is a picture of him right before going on stage at beyond tellerrand in 2019.)

CSS Tutorial: Style Table Rows To Look Like Cards

A client needed a more readable design for some of the tables on their website. The typical table styling was not cutting it, because the last column of said tables contained way more content than all the other columns.

Read more