A few years back I wrote about how to get Fancybox 1 working on WP galleries – specifically how to add a rel tag to an image anchor tag so that images would appear grouped in their correct galleries.

That all became obsolete with the introduction of the Gutenberg block editor, as images and galleries are now inserted into posts and pages in completely different ways.

Before, there were plenty of filters available to change image and wrapping anchor tags relatively easily, but my attempts to do something server-side and php-based with the block editor met with total failure. Instead I ended up upgrading to Fancybox 3 and using jQuery to sort pretty much everything out.

Read More →

Sorting out capabilities for custom post types is tricky. At least I think it is – mainly because it’s hard to figure out what you’re supposed to be doing. Both the code and the documentation seem somewhat opaque to me.

So this is my attempt at unraveling how it works – together with some different ways you might want to set up your custom post types. And it is an attempt, so if I’ve got something wrong or I’m not making sense, please let me know…

Read More →

I find admin notices are a pain. Every time I write a plugin there comes a point where I think “I’ll just add in some notices to help the user” – and two hours later…

I kept thinking, “This should be so much easier”, so finally I sat down and wrote a class that I can use in any plugin to handle pretty much every admin notice scenario I could think of. It’s available on Github for download with how-to explanatory info and examples.

Read More →

This post is one of the examples of how the Hooked Editable Content plugin can be used.

I’ve created this post as a user with the Author role, and in doing that I’ve also been able to add the gallery of two racing car images you can see beneath the main menu.

To do that, I used the hooked editor which was available to me on the Edit Post screen, below the main post content editor. As you can see, it’s just a normal WP Editor, but with the title Hooked Editor: Images after Main menu and some instructions. Using that editor, I could add a gallery of images in the normal way – just as if I was adding a gallery in the content of a normal post.

Read More →

Recently I was working on a child theme of Storefront, which by default changes the colour of whichever menu item you’re hovering over. If you hover over the example menu below you’ll see what I mean.

  • Home
  • Blog
  • Contact

Works fine, right? Then I decided I’d like the selected menu to show in a different colour to help users know where they are. So for example if you’re on the home page, the menu would look like this:

  • Home
  • Blog
  • Contact

But now when you hover over the menu items, there’s a problem. Move the cursor between Home and Blog and a small gap between the menu items is glaringly obvious. The same gap is between all the items actually, but it’s not noticeable in the first example.

Read More →

I’m using Fancybox as a lightbox on this site, which was working fine for individual images. But when I posted the gallery of three images in my previous post, I realised the images weren’t linked together in a gallery in a way Fancybox understood. What’s needed is the rel attribute, and a quick google showed loads of people suggesting the same snippet to add to the functions.php file:

/**
 * Give a rel attribute to all gallery images in a post
 */
function st_add_rel_attribute( $link ) {
    return str_replace( '<a href', '<a rel="st-gallery" href', $link );
}
add_filter( 'wp_get_attachment_link', 'st_add_rel_attribute' );
Read More →

Just finished reading The Year without Pants by Scott Berkun, which is about his 2 year tenure at Automattic working for WordPress.com. Inspiring and worth a look, but not what I’m here to say.

Unusually for me, because it was borrowed from a friend, the book was in traditional paper form instead of downloaded to my Kindle. I love the convenience of the Kindle, but I do get it when people say to me, “It’s just not the same – I need the feel of the paper”. And as a slight aside, before my main point, I have found I need the location feature turned on when reading my Kindle. I am disconcerted that I don’t know how far I am through the book. With the paper version, I know instinctively because of the size of the wedges of paper either side of my thumb. Not so with an e-reader, and it turns out I like to know where I am in the story arc.

Read More →