Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create custom css box for a wordpress plugin

Tags:

wordpress

I have looked all over the web for a tutorial or code on how to create a custom css textfield for a plugin. Would really appreciate if someone could help. Thanks!

like image 608
mattesj Avatar asked Jun 16 '26 03:06

mattesj


1 Answers

ok bro lets do it

in plugin main file you must register setting for css field

Like:

register_setting('settings-group', 'css_field');

And then in your settings file where you create setting form (e.g. setting.php)

<textarea cols="50" rows="20" name="css_field" id="css_field" tabindex="1"><?php echo get_option('css_field') ?></textarea>

Then call it in your template under the get_header();

<style type="text/css">
    <?php echo get_option('css_field'); ?>
</style>

or you can add in header in plugin main file Like:

function wp_css_custome(){
?>
    <style type="text/css">
        <?php echo get_option('css_field'); ?>
    </style>
<?php
}
add_action('wp_head','wp_css_custome');

Hope this will help you :)

like image 171
deemi-D-nadeem Avatar answered Jun 18 '26 01:06

deemi-D-nadeem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!