I'm usually do dynamic-style.php file for making dynamic css codes from theme options, shortcode, customizer and all others.

But, you may already know it'll slow down our site speed. I would highly target to have custom style format in our header or footer echo like within : style tag.

Also, searching for hover option within our shortcode it self? I done that by adding fields. But, little confusion about how to echo hover within our style="" itself. So, it should be fine if each shortcode have unique class name and we can add :hover there.

Like :

.element-class-9123 {color: white;}
.element-class-9123:hover {color: black;}

If you've better method, please let me know. It would really helpful for me.


  • I don't know exactly what you are asking. Would you please try to clarify? – s_ha_dum Jan 22 '16 at 13:57
  • I want, button normal and hover background color and text color. That is need to make it from php code. I've added WordPress shortcode fields. Like : [button text_color="black" text_hover_color="white"] Is it possible with php code? Or just have look below brian comment : He mentioned unique id in php code. Which is awesome! But don't know how to use it within our page style tag. – Ansif Feb 1 '16 at 11:12

You can use uniqueid() from php. It'll generate unique id for your css selector.

Or if you use any WordPress core pages like : archive, tags, category pages, please refer following article: 9 Ways to Set Dynamic Body Ids via PHP and WordPress

  • Thanks for your suggestion, i've looked but it's little hard to use within our shortcode. Iike i want that all css codes in : <style> tag in our page header or footer. Is is possible? – Ansif Feb 1 '16 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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