WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Самая быстрая Тема-конструктор для WordPress
функция не описана

_filter_query_attachment_filenames() WP 4.7.0

Filter the SQL clauses of an attachment query to include filenames.

Хуков нет.


Строку[]. The modified array of clauses.


_filter_query_attachment_filenames( $clauses );
$clauses(строка[]) (обязательный)
An array including WHERE, GROUP BY, JOIN, ORDER BY, DISTINCT, fields (SELECT), and LIMITS clauses.


  • Global. wpdb. $wpdb WordPress database abstraction object.

Список изменений

С версии 4.7.0 Введена.

Код _filter_query_attachment_filenames() WP 5.5.1

function _filter_query_attachment_filenames( $clauses ) {
	global $wpdb;
	remove_filter( 'posts_clauses', __FUNCTION__ );

	// Add a LEFT JOIN of the postmeta table so we don't trample existing JOINs.
	$clauses['join'] .= " LEFT JOIN {$wpdb->postmeta} AS sq1 ON ( {$wpdb->posts}.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )";

	$clauses['groupby'] = "{$wpdb->posts}.ID";

	$clauses['where'] = preg_replace(
		"/\({$wpdb->posts}.post_content (NOT LIKE|LIKE) (\'[^']+\')\)/",
		'$0 OR ( sq1.meta_value $1 $2 )',

	return $clauses;