posts_clauses

最后更新于:2021-11-27 14:44:54

apply_filters_ref_array( ‘posts_clauses’, string[] $clauses, GC_Query $query )

Filters all query clauses at once, for convenience.

参数

$clauses

(string[])
Associative array of the clauses for the query.

$query

(GC_Query)
The GC_Query instance (passed by reference).

源文件

文件: gc-includes/class-gc-query.php

View on Trac

<?php
/**
 * Alter different parts of the query
 * 
 * @param array $pieces
 * 
 * @return array $pieces
 */
function intercept_query_clauses( $pieces )
{
	echo '<style>#post-clauses-dump { display: block; background-color: #777; color: #fff; white-space: pre-line; }</style>';
	// >>>> Inspect & Debug the Query 
	// NEVER EVER show this to anyone other than an admin user - unless you're in your local installation
	if ( current_user_can( 'manage_options' ) )
	{
		$dump = var_export( $pieces, true );
		echo "< PRE id='post-clauses-dump'>{$dump}</ PRE >";
	}

	return $pieces;
}
add_filter( 'posts_clauses', 'intercept_query_clauses', 20, 1 );