Pulling in Column Count in Custom Gallery

Sprintf is a way to use variables within a string easily. %d designates a digit and %s is any string. So think of it like this sprintf( ‘<div class=”%s”>%s</div>’, $var1, $var2 ); So for your example, you’d need something like: $output = sprintf( ‘<div class=”gallery gallery-columns-%s” itemprop=”image” itemscope itemtype=”http://schema.org/ImageGallery”>%s</div>’, $columns, $output ); The only thing … Read more

WordPress Gallery is not displaying

Waited a lot but couldn’t find an answer… I found the issue but doesn’t know how to resolve it. But fortunately there is a way around it. I have been using wordpress’s pre_get_posts hook to set a tax_query which looks like this: add_action( ‘pre_get_posts’, ‘homeInjector’ ); function homeInjector( $query ) { if ( $query->is_home() ) … Read more

Add title tag to image in wordpress gallery

The ‘img’ tag is built via the theme code for display on the page. So, you would have to modify the theme code to add to the img tag. Note that modifying theme code directly is not generally advised, as a theme update will overwrite your changes. “Child” themes are best used for this modification.

Output all images from gallery inside a slider

Ok, so, I found this function, but it wasn’t in the codex. It came from Pippin’s Plugins, just to clarify for any future readers. It appears this function was used as a filter added onto the content, and will only run when filtering existing content, because it’s retrieving & replacing the galleries placed inside the … Read more

Extract Gallery picture info from empty gallery shortcode

I don’t like how WordPress processes the gallery shortcode. This is some slightly modified code I had that I’ve used to get the images in a gallery. In this example, the attachments (and thus their IDs) would only be available after the gallery shortcode has been processed. If you’re looking to display different HTML than … Read more