0

I have a certain amount of data stored in a transient through a custom developed plugin ( just for this one website ). The transient contains one big array of data that I get from an external API. The API response was really slow and I needed pretty large amounts of data, that's why I went with transients.

On the site I have made functionality that breaks the array up in smaller pieces to display all the data my users need to see on the appropriate pages.

I would like to make this searchable through a widget, just like the default WP search widget. I think i know how I can accomplish this, i've made custom widgets before. However, I would like to know if:

A. This is a good idea in general? I'm quite new to transients.

B. Is there a better ( already existing ) way to accomplish this? I've searched for already existing plugins but i could not find one that had what I needed ( which led me to think that it might not be a good idea at all ).

Again, I have absolutely no problem with building my own widget plugin for this site. However, I thought it would be a good idea to check this before I set about to reinvent the wheel.

1 Answer 1

1

A. This is a good idea in general? I'm quite new to transients.

No, not really. If your data is for display and search then it's not really 'transient', is it?

You should store the data properly in a more permanent place and periodically sync it. If the data from this API makes sense as a 'post', then storing it in custom post types might be the way to go, but you'll probably need a custom table.

How to create a custom table, store data from an API in it, sync it with the API and search it is far too much to cover in a single answer on this site, however there are dozens of tutorials online about working with custom tables. Start from there, then introduce the external API and syncing later.

B. Is there a better ( already existing ) way to accomplish this? I've searched for already existing plugins but i could not find one that had what I needed ( which led me to think that it might not be a good idea at all ).

If the API is public and well-known then it's possible someone has already built something, but you'd need to search. This is not the place to look for plugin recommendations.

If an existing solution doesn't exist, you'd need to build it yourself, but there's a lot of components involved, as I mentioned above. I would give up on the idea of transients immediately though. They are not appropriate for this use.

1
  • Thanks for the detailed answer. I had a feeling i wasn't going in the proper direction. I actually started off getting everything as custom post types but somewhere along the way I switched to transients. So I guess I should've stuck to my first choice.
    – El Klo
    Sep 6, 2018 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.