rep__agency_id
rep__agency_id is a custom query parameter used in the Malcolm HQ system to filter and retrieve posts related to a specific agency.
Product
How it Works
In Malcolm HQ, there are multiple custom post types that are associated with rep_agency by agency_id. The rep__agency_id parameter allows efficient retrieval of these CPT posts based on an associated agency ID.
Unlike standard WordPress meta queries (meta_query), which rely on wp_postmeta, this parameter queries a custom database table, making filtering significantly more efficient. Since the data is stored in a custom table, filtering is optimized for performance and does not require additional meta_query conditions.
Applicable CPT’s
- Employees (
rep_employee) - Listings (
rep_listing) - Reviews (
rep_review) - Projects (
rep_project)
Accepted Values
accepts an integer agency ID:rep__agency_id
- Integers – An agency ID that should be used to filter the results.
Usage
You can use rep__agency_id in your WP_Query arguments to retrieve Malcolm HQ CPT’s posts associated with a specific agency ID.
Example
$args = array(
'post_type' => 'rep_listing', // Custom post type.
'rep__agency_id' => 123, // Filter by agency ID.
);
// Execute the query and retrieve results.
$query = new WP_Query( $args );
The query will retrieve rep_listing posts where the agency_id matches the specified agency ID 123 |