I have a plugin meta box (in the Wordpress admin) with the following fields and values:

Name of the div class selector= featured_content
Font family= Verdana
Font color= #000

They are stored in the Wordpress post meta table.

In the Wordpress front end, one of the content template has this div:

<div class="featured_content">
The quick brown fox jumps over the lazy dog.

How would I communicate with the Wordpress front end from my Wordpress meta box settings for that div? So that when the page is loaded containing the div class selector name of "featured_content", proper styling would be implemented based on the backend meta box settings.

I am thinking of running a JS code to scan all id and class selectors then query via AJAX to retrieve the settings and implement them, but I'm not sure if this is the best way.

Thank you for any tips.

  • Not sure whether I understand this question properly, but should not the CSS for .featured_content take care of this? If the concern is how to have your own CSS files included in the wp-admin section, then this can be done. – Prasad Ajinkya Dec 13 '12 at 5:45
  • featured_content is generated by another plugin. I only add a new meta boxes below the admin section of that plugin using my new plugin as shown in my question. So if the page is loaded, how is it possible to retrieve the meta box settings and implement them to the div of interest? – Emerson Maningo Dec 13 '12 at 5:47

The answer is really simple, I never thought at first. You will simply create a custom CSS function inside your plugin and then use PHP to output the meta values and hook that to wp head.

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.