I'm trying to link to a custom css file in a new folder of a small plugin I'm trying to make. I can't seem to get it to work. This is the line I have
echo '<link rel="stylesheet" href="' . esc_url( plugins_url( 'public/css/front-end/uwc-tabs-style.css', __FILE__)) . '" >';
I've also tried the following but neither works.
echo '<link rel="stylesheet" href="' . plugins_url( 'public/css/front-end/uwc-tabs-style.css', __FILE__) . '" >';
As an edit. This is for an options result. eg. Select option 1 it returns the above stylesheet on the frontend
I'm trying to link to a custom css file in a new folder of a small plugin I'm trying to make. I can't seem to get it to work. This is the line I have
echo '<link rel="stylesheet" href="' . esc_url( plugins_url( 'public/css/front-end/uwc-tabs-style.css', __FILE__)) . '" >';
I've also tried the following but neither works.
echo '<link rel="stylesheet" href="' . plugins_url( 'public/css/front-end/uwc-tabs-style.css', __FILE__) . '" >';
As an edit. This is for an options result. eg. Select option 1 it returns the above stylesheet on the frontend
I would use wp_enqueue_style()
for this instead of echoing a <link>
.
I worked it out. In case anyone else comes here looking for the answer here it is. I just had to add dirname(__FILE__)
in place of __FILE__
echo '<link rel="stylesheet" href="' . esc_url( plugins_url( 'public/css/front-end/uwc-tabs-style.css', dirname(__FILE__))) . '" >';