پرش به محتویات

"Filter: bricks/query_filters/custom_field_index_rows"

ردیف‌های نمایه تولید شده برای یک فیلد سفارشی در سیستم Query Filters را فیلتر می‌کند. این به ارائه‌دهندگان (مانند ACF، Meta Box) یا کد سفارشی اجازه می‌دهد تا نحوه فهرست‌بندی داده‌های میدانی پیچیده برای فیلتر کردن را مدیریت کنند.

پارامترها

  • $rows (array): Array of index rows. Each row is an associative array representing a filterable value.
  • $object_id (int): The ID of the object (post, term, user) being indexed.
  • $meta_key (string): The meta key of the custom field.
  • $provider (string): The data provider (e.g., acf, metabox).
  • $object_type (string): The type of object (post, term, user).

نمونه استفاده

add_filter( 'bricks/query_filters/custom_field_index_rows', function( $rows, $object_id, $meta_key, $provider, $object_type ) {
    // Example: Index a custom serialized field
    if ( $meta_key === 'my_serialized_field' ) {
        $value = get_post_meta( $object_id, $meta_key, true );
        // ... parse value ...
        $rows[] = [
            'filter_value' => 'parsed_value',
            'filter_value_display' => 'Display Value',
            // ... other required fields ...
        ];
    }

    return $rows;
}, 10, 5 );