rep__agency_lid

rep__agency_lid is a custom query parameter used in the Malcolm HQ system to filter and retrieve posts related to a specific agency location. It ensures that only posts linked to a specific agency location are retrieved.


Product


How it Works

In Malcolm HQ, different custom post types (CPTs) are associated with rep_agency using agency_lid. The rep__agency_lid parameter enables efficient retrieval of posts linked to a specific agency location.

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.

The rep__agency_lid parameter applies to the following CPTs, with different behaviors based on the post type:


Applicable CPT’s

  • Listings (rep_listing)
    • The query filters by agency_lid, retrieving only listings assigned to the specified agency location.
  • Employees (rep_employee)
    • In Malcolm HQ, employees can be manually assigned to multiple agency locations.
    • Filtering checks:
      • If agency_lid matches the provided ID.
      • OR if manual_agency_lids contains the ID.

Accepted Values

rep__agency_lid accepts an integer agency ID:

  • Integers – An agency location ID that should be used to filter the results.

Usage

You can use rep__agency_lid in your WP_Query arguments to retrieve Malcolm HQ CPT’s posts associated with a specific agency location ID.


Example

$args = array(
    'post_type'        => 'rep_listing', // Custom post type.
    'rep__agency_lid'   => 123, // Filter by agency Location ID.
);

// Execute the query and retrieve results.
$query = new WP_Query( $args );
The query will retrieve rep_listing posts where the agency_lid matches the specified agency location ID 123
Please note that the example is for reference only and may need adjustments depending on the structure of your code.

Related

Use to filter posts based on various criteria.

Use to filter posts based on various criteria.