CRP_Core_Query
Contextual Related Posts: Main CRP Class.
Namespace: WebberZone\Contextual_Related_Posts
Since: 3.0.0
Source: includes/class-crp-core-query.php line 25
Methods
__construct()
Main constructor.
Since: 3.0.0
Line: 145
public function __construct( $args = ... );
| Type | Name | Description |
|---|---|---|
array|string | $args | The Query variables. Accepts an array or a query string. |
hooks()
Initialise search hooks.
Since: 3.5.0
Line: 165
public function hooks( );
prepare_query_args()
Prepare the query variables.
Since: 3.0.0
Line: 193
public function prepare_query_args( $args = ... );
| Type | Name | Description |
|---|---|---|
string|array | $args | { |
get_match_sql()
Get the MATCH sql.
Since: 3.0.0
Line: 547
public function get_match_sql( ): string;
Returns: string — Updated Fields
is_backlogged()
Check if MySQL is currently under heavy load.
Since: 4.2.0
Line: 676
public function is_backlogged( ): bool;
Returns: bool — True if the database is considered backlogged.
pre_get_posts()
Modify the pre_get_posts clause.
Since: 3.5.0
Line: 739
public function pre_get_posts( $query );
| Type | Name | Description |
|---|---|---|
\WP_Query | $query | The WP_Query instance. |
posts_fields()
Modify the SELECT clause - posts_fields.
Since: 3.0.0
Line: 784
public function posts_fields( $fields, $query ): string;
| Type | Name | Description |
|---|---|---|
string | $fields | The SELECT clause of the query. |
\WP_Query|\CRP_Query | $query | The WP_Query or CRP_Query instance. |
Returns: string — Updated Fields
posts_join()
Modify the posts_join clause.
Since: 3.0.0
Line: 826
public function posts_join( $join, $query ): string;
| Type | Name | Description |
|---|---|---|
string | $join | The JOIN clause of the query. |
\WP_Query|\CRP_Query | $query | The WP_Query or CRP_Query instance. |
Returns: string — Updated JOIN
posts_where()
Modify the posts_where clause.
Since: 3.0.0
Line: 873
public function posts_where( $where, $query ): string;
| Type | Name | Description |
|---|---|---|
string | $where | The WHERE clause of the query. |
\WP_Query|\CRP_Query | $query | The WP_Query or CRP_Query instance. |
Returns: string — Updated WHERE
posts_orderby()
Modify the posts_orderby clause.
Since: 4.3.0
Line: 991
public function posts_orderby( $orderby, $query ): string;
| Type | Name | Description |
|---|---|---|
string | $orderby | The ORDER BY clause of the query. |
\WP_Query|\CRP_Query | $query | The WP_Query or CRP_Query instance. |
Returns: string — Updated ORDER BY
posts_groupby()
Modify the posts_groupby clause.
Since: 3.0.0
Line: 1083
public function posts_groupby( $groupby, $query ): string;
| Type | Name | Description |
|---|---|---|
string | $groupby | The GROUP BY clause of the query. |
\WP_Query|\CRP_Query | $query | The WP_Query or CRP_Query instance. |
Returns: string — Updated GROUP BY
posts_request()
Modify the completed SQL query before sending.
Since: 3.0.0
Line: 1115
public function posts_request( $sql, $query ): string;
| Type | Name | Description |
|---|---|---|
string | $sql | The complete SQL query. |
\WP_Query|\CRP_Query | $query | The WP_Query or CRP_Query instance. |
Returns: string — Updated SQL query.
posts_pre_query()
Filter posts_pre_query to allow caching to work.
Since: 3.0.0
Line: 1170
public function posts_pre_query( $posts, $query ): \WP_Post[];
| Type | Name | Description |
|---|---|---|
\WP_Post[] | $posts | Array of post data. |
\WP_Query|\CRP_Query | $query | The WP_Query or CRP_Query instance. |
Returns: \WP_Post[] — Updated Array of post objects.
the_posts()
Modify the array of retrieved posts.
Since: 3.0.0
Line: 1240
public function the_posts( $posts, $query ): \WP_Post[];
| Type | Name | Description |
|---|---|---|
\WP_Post[] | $posts | Array of post objects. |
\WP_Query|\CRP_Query | $query | The WP_Query or CRP_Query instance (passed by reference). |
Returns: \WP_Post[] — Updated Array of post objects.
exclude_post_ids()
Exclude Post IDs. Allows other plugins/functions to hook onto this and extend the list.
Line: 1390
public function exclude_post_ids( $args ): array;
| Type | Name | Description |
|---|---|---|
array | $args | Array of arguments for CRP_Query. |
Returns: array — Array of post IDs to exclude.
should_cache()
Check if the output should be cached.
Since: 4.2.0
Line: 1494
public function should_cache( ): bool;
Returns: bool — True if the output should be cached.