Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how to get plugin directory path in wordpress

/**
 * Include CSS file for MyPlugin.
 */
function myplugin_scripts() {
    wp_register_style( 'foo-styles',  plugin_dir_url( __FILE__ ) . 'assets/foo-styles.css' );
    wp_enqueue_style( 'foo-styles' );
}
add_action( 'wp_enqueue_scripts', 'myplugin_scripts' );

Answer
http://example.com/wp-content/plugins/my-plugin/assets/foo-styles.css
Source by developer.wordpress.org #
 
PREVIOUS NEXT
Tagged: #plugin #directory #path #wordpress
ADD COMMENT
Topic
Name
3+6 =