Making a “Skip To Content” Link in WordPress

A “skip to content” link is a link, typically hidden from view, usually at the very top of the page source, to navigate directly to the main content of the page. There’s one on this very blog! You can see it if you view source, and you can also see it if you tab to it, as per wp.org accessibility guidelines. There are a few different components that make this happen, which I’ll explain in this post.

more… Making a “Skip To Content” Link in WordPress

Get WordPress to use image EXIF date as post_date for Attachments

By default, when you upload a media item, WordPress makes that a post of the ‘attachment’ post_type, giving it a post_date of whenever you upload it. Instead, you might want it to use the EXIF date for that image. In this post, I’ll walk through how to do that.

There are two steps we need to complete:

  1. Get the EXIF date.
  2. Get WordPress to use the EXIF date instead of the current time when saving the attachment for this first time.

more… Get WordPress to use image EXIF date as post_date for Attachments

WordPress Function to Determine if an Image is in Portrait Aspect Ratio

I’m sometimes concerned about finding photos with oddball aspect ratios so that they get an appropriate size in galleries. Imagine a pano at quarter width: It would be tiny; all panos need to be full width. Imagine a portrait at full-width: It would be way too tall; all portraits need to be something like quarter-width. I’ve dug into sjf_deh_is_pano() in the past, so let’s focus on its close cousin, sjf_deh_is_portrait().

more… WordPress Function to Determine if an Image is in Portrait Aspect Ratio

WordPress Function for Next/Prev Links in an Image Gallery

Imagine a photoblog that shows one image per page, very prominently. My photoblog is an example. But what if the main image is part of a gallery of images? When I say gallery, I mean a group of images uploaded to one parent post or page. In that case, we might want to show next/prev links to navigating to the adjacent images. It seems like a common concern, but I was surprised how tricky it was. Here’s the gist:

more… WordPress Function for Next/Prev Links in an Image Gallery

WordPress Gallery Shortcode Using Masonry.js

Masonry is a handy tool. Similar to bricks in a wall, it packs page elements into tetris-like layout. I’m often the “anti-framework” guy, though I feel better about leaning on something if WordPress does too. Indeed, the bundled themes use masonry to layout footer widgets. I’ll bite!

more… WordPress Gallery Shortcode Using Masonry.js