• Resolved Spencer Hill

    (@ws5f3dj7)


    Heya,
    I’m writing my first plugin and I’m trying to figure out how to include my stylesheet. I am trying the wp enqeue and it appears that it’s including it but it’s not inheriting any styles and I’m not sure why, can someone help? Thanks!

    [Code moderated as per the Forum Rules. Please use the pastebin]

Viewing 1 replies (of 1 total)
  • Thread Starter Spencer Hill

    (@ws5f3dj7)

    // BACK END STYLES
    function myExampleFunction() {
    
    	add_options_page('Example Plugin Options Name', 'Example Plugin Name', 'manage_options', 'example-plugin-name', 'example_plugin_admin_page');
    
    	wp_enqueue_style('style', '/wp-content/plugins/example-plugin/css/admin.css', '', '1.0', 'screen');
    
    }
    
    add_action('admin_menu', 'myExampleFunction'); // THIS ADDS THE CODE WITHIN THE myExampleFunction FUNCTION INTO THE HEAD OF THE ADMIN PAGE.
    
    // FRONT END STYLES
    function example_plugin_externals() {
    	echo '
    		<link rel="stylesheet" type="text/css" href="path/to/styles">
    
    		<script type="text/javascript" src="path/to/script"></script>
    	';
    }
    
    add_action('wp_head', 'example_plugin_externals'); // THIS ADDS THE CODE WITHIN THE EXAMPLE_PLUGIN_EXTERNALS FUNCTION INTO THE HEAD OF THE WEBSITES THEME.
    
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Including styles in a plugin, need help…’ is closed to new replies.