found_posts Hook in WPFTS

The found_posts filter in WordPress allows modification of the number of found posts (found_posts) after it has been determined by WordPress. WPFTS uses this filter for correct pagination in split query mode (split_the_query).

What WPFTS does when found_posts is called:

  1. Applying the filter: WPFTS doesn’t directly change the found_posts value, but simply passes it through the filter apply_filters_ref_array( 'found_posts', array( $wpq->found_posts, &$wpq ) );. This allows other plugins and themes to modify the number of found posts if necessary. WPFTS itself does not change this value. This filter is called in the WPFTS_Search::wpq_set_found_posts() method, which in turn is only called in the case of a split query.

Important functions involved in processing found_posts:

  • WPFTS_Search::wpq_set_found_posts() (internal method, similar to the private method WP_Query::set_found_posts())
  • apply_filters_ref_array('found_posts', ...)

How to use it in addon development:

Addon developers can use the found_posts filter to change the number of found posts if necessary. However, in the context of WPFTS, this filter is mainly used for compatibility and does not carry specific plugin logic.

Additional notes:

  • The found_posts filter is called after WordPress has determined the number of found posts.
  • WPFTS does not directly change the found_posts value, but simply passes it through the filter.
  • This filter is called in the context of the WPFTS_Search::wpq_set_found_posts() method, which is only executed when using a split query.