braekling / WP-Matomo

Official WP-Matomo (former WP-Piwik) repository
GNU General Public License v3.0
30 stars 28 forks source link

use global $wp_query->found_posts instead of creating a new WP_Query to count search results in trackSiteSearch mode, for better performance #111

Closed theodejager closed 1 year ago

theodejager commented 1 year ago

When "Track search: Use Matomo's advanced Site Search Analytics feature" is selected, an extra/new WP_Query is ran to count the number of results and push them to Matomo. This can really slow down searches.

Using the already available global $wp_query object avoids having to run an extra query.