0

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

0

I would use wp_enqueue_style() for this instead of echoing a <link>.

  • That's a much better way. I don't know why I didn't do it like that before The link worked, but the enqueuing will be much better all around. – John Cook Feb 26 at 8:39
-1

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__))) . '" >';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.