I’m trying to figure out, how to add search results from external database to WordPress query. I googled this task, but looks like nobody ever wanted to achieve this. Which is a bummer.
In short, I need to do the following:
- Query external database by the same keyword (done).
- Process results and create an array similar to WP posts array (done).
- Add results from external database to WP query, maintaining proper pagination, post count etc.
I have zero issues achieving the same task on Joomla or OpenCart, but WordPress is a bit new to me. It has tons of hooks, but it’s hard to figure out the proper sequence of them.
I’ve already used a couple hooks like found_posts and the_posts, but pagination is totally broken, of course. It does show the proper number of pages, but only navigate to the end of WP results, ignoring the ones from external database.
Can somebody give me the right direction? I’m currently feeling a bit lost here.