I am thinking on using transient for my theme dynamic css in order to lower the site load.

Currently I have 15 php functions summed up in one collection function that do something like

 $css .= $element_name . '{color:'. esc_attr($value) .';}';

so basically just processors.

The collection function is outputted only once in the head so I thought of using transient for the output. Thing is that the css processing changes depending on page so I need to name my transient properly,

I was thinking about


but I am not sure if I can rely on get_queried_object_id() Are the ID's unique always or can it happen that 2 custom post types endup having same page ID 1 ?

Like portfolio and events.

To sum up,

Is get_queried_object_id() reliable to use with mixed post types ?

Would it be to much to use multiple transients ( for each wp page one ) ?

Should I use one transient for all pages ( an array )? It would be easier to remove it on theme settings change.

1 Answer 1


Unless you do something weird with your settings, transients will just make your code harder to read without adding any measurable performance value.

People that want performance should use object caching and page caching and your current code is probably already the best there is to utilize them. Transients will add almost nothing for them.

Transients make sense when you want to save several DB queries or network access, but your theme mods are already retrieved in one query from the DB, no way to improve on that.

  • You absolutely right. Tested and the speed performance is not different at all. Thnx for saving me time!
    – Benn
    Sep 13, 2016 at 10:34
  • @Mark Kaplun thanks for a great explanation, can you explain just a little bit in detail how to enable page caching, or point us to a link that shows us how to turn it on? Thanks
    – klewis
    Nov 4, 2016 at 14:40
  • @blackhawk, sorry, but I don't see any relevance to the answer, but really googling should give you at least 3 different plugins that do that. Nov 4, 2016 at 15:22

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.