在单个模板页面上放置一些 CSS 样式 - WordPress 插件
我正在为实习开发我的第一个 WordPress 插件。
我知道如何通过 wp_enqueue_style() 和 admin_enqueue_scripts 在管理页面上放置样式。我也知道 wp_enqueue_scripts。
我创建了一个自定义帖子类型来存储业务,并在“templates”文件夹中创建了一个名为“single-myCPT.php”的模板页面。
问题是:我不明白如何调用这个单页的css文件。
URL 类似于:mywebsite/myCPT/company
当我使用检查器并进入“网络”时,没有检测到 css 文件。
抱歉我的英语不好,我是一个法国人,想提高英语水平:)。
I'm developing my first WordPress plugin for an internship.
I know how to put style on the admin pages by wp_enqueue_style() and admin_enqueue_scripts. I also know wp_enqueue_scripts.
I created a custom post type to store businesses and a single template page in "templates" folder, called "single-myCPT.php".
The problem is: I don't understand how to call a css file for this single page.
The URL is like : mywebsite/myCPT/company
When I use the inspector and I go on "Network", there is no css file detected.
Sorry for my English, I'm a French guy who wants to improve that language :).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在前端(非管理)页面以及管理页面上使用 wp_enqueue_style() 和 wp_enqueue_script()。
为此,请使用 wp_enqueue_scripts 操作。
但是,您可能还应该在管理页面上包含前端 css;你可能需要它。
You can use wp_enqueue_style() and wp_enqueue_script() on front-end (non-admin) pages as well as admin pages.
Use the wp_enqueue_scripts action for the purpose.
But, you should probably also include your frontend css on your admin page; you may need it.