0

update: My plugin css does not work in the admin area. the below works on my website for public viewing but not on my admin page that i am building.

original question: I'm trying to make the html text "Make this red", red! I have a plugin I've added to my Wordpress plugins folder. In the "bio-plugin" folder in a file called "plugin.php" i have this code:

function register_bio_style(){
    wp_register_style('bio-style',plugins_url('css/bio-style.css',__FILE__), false, '1.0.0', 'all');
}
add_action('init','register_bio_style');

function enqueue_bio_style(){
    wp_enqueue_style( 'bio-style' );
}
add_action('wp_enqueue_scripts', 'enqueue_bio_style');

then later i have this html working:

<div class='bio_btn'>Make this text red</div>

then i have put bio-style.css in a folder called css and that is in the same directory as plugin.php

the bio-style.css code is:

.bio_btn{
color: red;
background: black;
}

the sentence "Make this red" appears on the (admin) page but it is black.

5
  • check is bio-style.css is linked properly Commented Dec 9, 2014 at 7:15
  • check with firebug if css and class calls properly? Commented Dec 9, 2014 at 7:16
  • try changing it to ../css/bio-style.css or /css/bio-style.css Commented Dec 9, 2014 at 7:16
  • well i cant find the bio-style.css link in the page source? Commented Dec 9, 2014 at 7:17
  • both ../css and /css did not work either Commented Dec 9, 2014 at 7:19

3 Answers 3

2

Try this :

    <?php 
    /*
    Plugin Name: Bio
    Plugin URI: URL of site
    Description: Custom Plugin
    Version: 1.0.0
    Author: Rohil
    Author URI: URL of author
    */

        // Register the style like this for a plugin:
        wp_register_style( 'biocss', plugin_dir_url( __FILE__ ) . 'css/bio-style.css' );


        // For either a plugin or a theme, you can then enqueue the style:
        wp_enqueue_style( 'biocss' );



    ?>

    <div class='bio_btn'>Make this text red</div>
Sign up to request clarification or add additional context in comments.

Comments

0

I cant make a comment here to ask so im just going to make a semi blind answer here.

Is there another css file with ".bio_btn" in it?

anyways there's probably a child css over riding it.

this is bad method but it will probably work

CSS

.bio_btn{
color: red !important;
background: black;
}

1 Comment

this didnt work either, it's not linking the css file. the css file is not being loaded in the page source
0

solved! For admin pages you must replace "init" with "admin_init" and "wp_enqueue_style" with "admin_enqueue_style" :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.