I found a kind of goofy kind of work around to this if anybody else is in my boat and willing to settle for using a light box instead of an actual page for each photo that can be commented on, shared/liked/etc.
But using the Fancybox lightbox script https://fancybox.net/ and the code below (pasted into your functions.php file), it will add the necessary “rel” to each thumbnail in your gallery and open each photo in a lightbox instead. For some reason Wodpress will be able to distinguish which photo is suppose to come next and they will click through properly this way.
Though I’m still apprehensive about using this work around if WordPress isn’t planning on supporting the gallery function in the future.
class WPFancyBox {
// Constructor
function WPFancyBox() {
$urlpath = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__));
add_filter('wp_get_attachment_link', array(&$this,'add_rel'));
}
/*
* Add rel="gallery-$id" to attachment links
*/
function add_rel($link) {
global $post;
// a mild cheat. group by post id. the gallery_shortcode() $instance
// static var would be better, but we can't get to it.
$id = $post->ID;
// First, see if there's already a 'rel' attribute in the link:
$atag = preg_match('#<a\s+(.*?)(rel=([\'"])(.*?)\3)(.*?)>(.*)#i', $link, $matches);
if ($atag) {
// Match found. Let's put Humpty Dumpty back together again:
$quot = $matches[3];
$relval = $quot . $matches[4] . " gallery-{$id}" . $quot;
$before = $matches[1];
$after = $matches[5];
$rest = $matches[6];
$link = "<a {$before}rel={$relval}{$after}>{$rest}";
} else {
$atag = preg_match('#<a\s+(.*?)>(.*)#i', $link, $matches);
if ($atag) {
// This is a much simpler reassembly
$innards = $matches[1];
$rest = $matches[2];
$relval = "gallery-{$id}";
$link = "<a {$innards} rel='lightbox'>{$rest}";
}
}
return $link;
}
}
function wpfb_init() {
//global $wpfb;
$wpfb = new WPFancyBox();
}
add_action('init', 'wpfb_init');