0

i'm trying to add bootstrap file into my custm wordpress plugin but not succeeded. i included this "function my_plugin_scripts() { if( is_admin() ){ wp_enqueue_script('admin_js_bootstrap',$plugin_url.'admin/js/bootstrap.min.js',false,'3.3.7',false); wp_enqueue_style('admin_css_bootstrap', $plugin_url.'admin/css/bootstrap.min.css',true,'3.3.7','all'); } } add_action( 'wp_enqueue_scripts', 'my_plugin_scripts' );"

and

" add_action( 'wp_print_styles', 'add_my_plugin_stylesheet' ); function add_my_plugin_stylesheet() { wp_register_style('mypluginstylesheet', '/wp-content/plugins/postgrid/style.css');

wp_register_style('prefix_bootstrap', '//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'); wp_enqueue_style('mypluginstylesheet'); wp_enqueue_style('prefix_bootstrap');"

codes and others codes but not work.

Here is screenshot of the code enter image description here

Please help me here and guide me where to add code on plugin file or functions.php file.

Thank you.

i need a perfect solution for it.

1 Answer 1

0

In a plugin (inside a PHP class)

Assumes the Plugin class name is 'my_plugin'.
Assumes the Plugin directory is named 'my-plugin'.
Assumes the Plugin style sheet is named 'plugin.css'.

<?php
class WPDocs_My_Plugin_Stylesheet {

    /**
     * Constructor.
     */
    function __construct() {
        // Register stylesheet.
        add_action( 'wp_enqueue_scripts', array( $this, 'register_plugin_styles' ) );
    }

    /**
     * Registers and enqueues stylesheet.
     */
    public function register_plugin_styles() {
        wp_register_style( 'my-plugin', plugins_url( 'my-plugin/css/plugin.css' ) );
        wp_enqueue_style( 'my-plugin' );
    }
}
new WPDocs_My_Plugin_Stylesheet();

Reference wp_register_style

Sign up to request clarification or add additional context in comments.

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.