WP_Widget_Custom_HTML::_filter_gallery_shortcode_attrs( array $attrs ): array

Filters gallery shortcode attributes.

Description

Prevents all of a site’s attachments from being shown in a gallery displayed on a non-singular template where a $post context is not available.

Parameters

$attrsarrayrequired
Attributes.

Return

array Attributes.

Source

public function _filter_gallery_shortcode_attrs( $attrs ) {
	if ( ! is_singular() && empty( $attrs['id'] ) && empty( $attrs['include'] ) ) {
		$attrs['id'] = -1;
	}
	return $attrs;
}

Changelog

VersionDescription
4.9.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.