• I’ve coded a custom post type page, and I’ve realized that I’ve generated a lot of queries to the database. Hence, the posts that have this template applied to them load extremely slow compared to the rest of the site.

    I was hoping I could either cache the queries or someone could help optimize this code further by maybe reducing the queries.

    Anyway, I looked into Transient API and how to exactly cache queries, and I can’t seem to understand it exactly. The code generates a list, which remains pretty static and doesn’t need to change. However, the list may get updated every now and then, maybe within a week or so. If I am able to cache the queries for that long, how would I go about doing that. Also if a new post was added, would it show in the list if the query has been cached for 1 week?

    If someone could help with adding Transeint code on this custom code, it would be great.

    https://pastebin.com/yUaBT5VG

  • The topic ‘Adding Transient Code / Optimize to the following Custom Code’ is closed to new replies.