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

"Filter: bricks/combined_search/post_ids"

لیست شناسه های پستی را که با منطق جستجوی ترکیبی بازگردانده شده اند (در فیلترهای جستجوی AJAX استفاده می‌شود) فیلتر می‌کند. این به شما این امکان را می‌دهد که پس از اجرای عبارت جستجوی اولیه، پست ها را از نتایج جستجو اضافه یا حذف کنید.

پارامترها

  • $post_ids (array): Array of found post IDs.
  • $search_fields (array): Array of post fields being searched (e.g., ['title', 'content', 'excerpt']).
  • $meta_fields (array): Array of meta keys being searched.
  • $search_term (string): The search term entered by the user.
  • $filter_id (string): The ID of the filter element initiating the search.
  • $query_id (string): The ID of the query loop being filtered.

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

add_filter( 'bricks/combined_search/post_ids', function( $post_ids, $search_fields, $meta_fields, $search_term, $filter_id, $query_id ) {
    // Example: Always include a specific sticky post in search results
    $sticky_post_id = 123;
    if ( ! in_array( $sticky_post_id, $post_ids ) ) {
        $post_ids[] = $sticky_post_id;
    }

    return $post_ids;
}, 10, 6 );