管理员页面上的Wordpress插件css
更新:我的插件css在管理区不起作用。以下内容在我的网站上公开查看,但不在我正在构建的管理页面上 原始问题: 我想让html文本变成红色,红色! 我已经在Wordpress插件文件夹中添加了一个插件。在名为plugin.php的文件的bio plugin文件夹中,我有以下代码:管理员页面上的Wordpress插件css,css,wordpress,plugins,Css,Wordpress,Plugins,更新:我的插件css在管理区不起作用。以下内容在我的网站上公开查看,但不在我正在构建的管理页面上 原始问题: 我想让html文本变成红色,红色! 我已经在Wordpress插件文件夹中添加了一个插件。在名为plugin.php的文件的bio plugin文件夹中,我有以下代码: function register_bio_style(){ wp_register_style('bio-style',plugins_url('css/bio-style.css',__FILE__), fa
function register_bio_style(){
wp_register_style('bio-style',plugins_url('css/bio-style.css',__FILE__), false, '1.0.0', 'all');
}
add_action('init','register_bio_style');
function enqueue_bio_style(){
wp_enqueue_style( 'bio-style' );
}
add_action('wp_enqueue_scripts', 'enqueue_bio_style');
然后,我让这个html工作:
<div class='bio_btn'>Make this text red</div>
“让这个红色”这句话出现在管理页面上,但它是黑色的。我不能在这里发表评论,所以我只想在这里半盲回答 是否还有另一个css文件包含.bio_btn 不管怎样,可能有个孩子骑在上面 这是一种糟糕的方法,但它可能会起作用 CSS 试试这个:
<?php
/*
Plugin Name: Bio
Plugin URI: URL of site
Description: Custom Plugin
Version: 1.0.0
Author: Rohil
Author URI: URL of author
*/
// Register the style like this for a plugin:
wp_register_style( 'biocss', plugin_dir_url( __FILE__ ) . 'css/bio-style.css' );
// For either a plugin or a theme, you can then enqueue the style:
wp_enqueue_style( 'biocss' );
?>
<div class='bio_btn'>Make this text red</div>
解决了!对于管理页面,您必须将init替换为admin_init,将wp_enqueue_样式替换为admin_enqueue_样式:检查是bio-style.css链接是否正确检查css和类调用是否正确?尝试将其更改为../css/bio-style.css或/css/bio-style.csw我在页面源中找不到bio-style.css链接?无论是../css还是/css都没有这也不起作用,它没有链接css文件。css文件未加载到页面源中
.bio_btn{
color: red !important;
background: black;
}
<?php
/*
Plugin Name: Bio
Plugin URI: URL of site
Description: Custom Plugin
Version: 1.0.0
Author: Rohil
Author URI: URL of author
*/
// Register the style like this for a plugin:
wp_register_style( 'biocss', plugin_dir_url( __FILE__ ) . 'css/bio-style.css' );
// For either a plugin or a theme, you can then enqueue the style:
wp_enqueue_style( 'biocss' );
?>
<div class='bio_btn'>Make this text red</div>