I'm building a very simple plugin to add social media icons to each page on a site that I'm working on.
I was expecting the following code to enqueue a stylesheet on the front-end:
function myplugin_styles_scripts() {
wp_enqueue_style( 'myplugin-style', plugin_dir_path( __FILE__ ) . '/css/style.css', array(), filemtime( plugin_dir_path( __FILE__ ) . '/css/style.css' ) );
}
add_action( 'wp_enqueue_scripts', 'myplugin_styles_scripts' );
On the front-end, I get the following error in the console:
https://testing.local/app/public/wp-content/plugins/social-icons/css/style.css?ver=1583931475 net::ERR_ABORTED 404
The directory and file exist within my plugin. What's causing this?
plugin_dir_path()
just a typo in the question? Because that should beplugin_dir_url()
.