wppaste
WordPress

apply_filters( 'gallery_style', string $gallery_style )

Since
2.5.0, 3.1.0, 5.3.0, 7.0.0
Filters the gallery shortcode's default CSS styles and opening HTML div container.

Description

To remove the CSS entirely, use the use_default_gallery_style filter instead:

add_filter( 'use_default_gallery_style', '__return_false' );

Compatibility

WordPress
since 7.0.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Parameters

Where this hook fires · 1

  • wp-includes/media.php:3033gallery_shortcode()

Source code

	 *              double for other themes.	 * @since 7.0.0 Removed the `type` attribute for any theme.	 *	 * @param string $gallery_style Default CSS styles and opening HTML div container	 *                              for the gallery shortcode output.	 */	$output = apply_filters( 'gallery_style', $gallery_style . $gallery_div ); 	$i = 0; 	foreach ( $attachments as $id => $attachment ) { 		$attr = ( trim( $attachment->post_excerpt ) ) ? array( 'aria-describedby' => "$selector-$id" ) : '';

Changelog

Introduced in 2.5.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

7.0.0
Removed the type attribute for any theme.from the docblock
5.3.0
Removed the type attribute for style tags when the theme supports HTML5 style, and changed the quotes from single to double for other themes.from the docblock
3.1.0
Added classes for number of columns and size to opening div.from the docblock
2.5.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.