Purpose
Replace or modify the query for a specific template object programmatically, allowing dynamic adjustments to the data source.
Usage
add_filter( "wr_template_object_replace_query", array( $this, "my_template_object_replace_query" ), 10, 3 );
Parameters
$query_identifier (string)
: The current query identifier used by the template object.$options (array)
: Additional options passed to the template.$selector (array)
: A selector for targeting specific parts of the template.
Use Case
This functionality is useful when:
- You need to dynamically switch the query source for a specific template object.
Implementation Example
add_filter( "wr_template_object_replace_query", array( $this, "my_template_object_replace_query" ), 10, 3 );
public function my_template_object_replace_query( $query_identifier, $options = array(), $selector = array() ) {
if ( !empty($options["identifier"] && $options["identifier"] === "my_template_object_identifier" ) ) {
return "my_query_identifier";
}
return $query_identifier;
}