$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>woocommerce offtopic - Trying to link to a custom css file in a new folder|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

woocommerce offtopic - Trying to link to a custom css file in a new folder

matteradmin10PV0评论

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

Share Improve this question edited Feb 26, 2019 at 1:48 John Cook asked Feb 26, 2019 at 1:33 John CookJohn Cook 673 silver badges9 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

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

comment list (0)

  1. No comments so far