Filter hook 'wp_allow_query_attachment_by_filename'

in WP Core File wp-includes/class-wp-query.php at line 1925

View Source

wp_allow_query_attachment_by_filename

Filter Hook
Description
Filters whether an attachment query should include filenames or not.

Hook Information

File Location wp-includes/class-wp-query.php View on GitHub
Hook Type Filter
Line Number 1925

Hook Parameters

Type Name Description
bool $allow_query_attachment_by_filename Whether or not to include filenames.

Usage Examples

Basic Usage
<?php
// Hook into wp_allow_query_attachment_by_filename
add_filter('wp_allow_query_attachment_by_filename', 'my_custom_filter', 10, 1);

function my_custom_filter($allow_query_attachment_by_filename) {
    // Your custom filtering logic here
    return $allow_query_attachment_by_filename;
}

Source Code Context

wp-includes/class-wp-query.php:1925 - How this hook is used in WordPress core
<?php
1920  		 *
1921  		 * @since 6.0.3
1922  		 *
1923  		 * @param bool $allow_query_attachment_by_filename Whether or not to include filenames.
1924  		 */
1925  		$this->allow_query_attachment_by_filename = apply_filters( 'wp_allow_query_attachment_by_filename', false );
1926  		remove_all_filters( 'wp_allow_query_attachment_by_filename' );
1927  
1928  		// Parse meta query.
1929  		$this->meta_query = new WP_Meta_Query();
1930  		$this->meta_query->parse_query_vars( $q );

PHP Documentation

<?php
/**
		 * Filters whether an attachment query should include filenames or not.
		 *
		 * @since 6.0.3
		 *
		 * @param bool $allow_query_attachment_by_filename Whether or not to include filenames.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/class-wp-query.php
Related Hooks

Related hooks will be displayed here in future updates.