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

"Filter: bricks/query_api/total_pages"

تعداد کل صفحات محاسبه شده برای یک حلقه جستجوی API خارجی را فیلتر می‌کند. این زمانی مفید است که ساختار پاسخ API برای صفحه بندی با منطق استخراج استاندارد Bricks مطابقت نداشته باشد.

پارامترها

  • $total_pages (int): The calculated total number of pages.
  • $element_id (string): The ID of the query element.
  • $query_api (object): The Bricks\Integrations\Query\Query_API instance.

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

add_filter( 'bricks/query_api/total_pages', function( $total_pages, $element_id, $query_api ) {
    // Example: Set total pages for a specific API query
    if ( $element_id === 'my_api_loop' ) {
        // Assume you stored the total in a custom property or need a fixed value
        return 10;
    }

    return $total_pages;
}, 10, 3 );