WordPress.org

Ready to get started?Download WordPress

Forums

Creating or edit stylesheet in plugin (7 posts)

  1. uncommonjoe
    Member
    Posted 6 years ago #

    I know this is possible because I've seen other plugins add a stylesheet for their plugin. How would I go about doing this or editing the current stylesheet through the plugin?

    Thanks.

  2. mendezki
    Member
    Posted 6 years ago #

    Using something like this should do the trick:

    add_action('wp_head', 'yourplugin_wp_head');
    function yourplugin_wp_head() {
    	echo '<link rel="stylesheet" type="text/css" media="screen" href="' . get_bloginfo('wpurl') . '/wp-content/plugins/yourplugin/yourplugin.css" />';
  3. uncommonjoe
    Member
    Posted 6 years ago #

    As my luck should have it, it doesn't work for me. I tried placing it in multiple places to no avail. Any suggestions?

  4. Kafkaesqui

    Posted 6 years ago #

    Yep, make sure:

    <?php wp_head(); ?>

    actually appears in the <head> of your theme. Without it, the add_action() produces no results.

  5. uncommonjoe
    Member
    Posted 6 years ago #

    I have that in my <head> already.

  6. Kafkaesqui

    Posted 6 years ago #

    Then likely you are doing something wrong in your code. Any chance you can upload it somewhere for a look see?

    You could try:

    http://wordpress.pastebin.ca/

    and reply back with the url provided.

  7. uncommonjoe
    Member
    Posted 6 years ago #

    Well the problem is it's it's styling the blog but not the plugin.

    For an example, I have a div called #foo and I want to style it in my plugin but it doesn't it just styles that div in my theme.

    Anyone know how to fix that?

Topic Closed

This topic has been closed to new replies.

About this Topic