【问题标题】:Is there a way to style add_menu_page() in WordPress?有没有办法在 WordPress 中设置 add_menu_page() 的样式?
【发布时间】:2020-04-21 00:36:36
【问题描述】:

我正在使用add-menu-page 函数为我的 WordPress 主题添加某种欢迎页面。有什么方法可以让我不使用内联样式来设置页面内部的样式,还是我使用add-menu-page 用于错误的目的?

【问题讨论】:

标签: php css wordpress wordpress-theming


【解决方案1】:

是的,这很简单。这是我要做的:

  1. 创建 CSS 文件
  2. 使用admin_enqueue_scripts 使用this answer from the WP Stack Exchange 之类的代码将CSS 文件排入队列。

在此处重复该代码以防其他答案被删除:

function my_admin_enqueue( $hook_suffix ) {
    if( 'appearance_page_theme-options' === $hook_suffix ) {       
        wp_enqueue_style('my-theme-settings', get_template_directory_uri() . '/styles/theme-settings.css');        
    }
}
add_action( 'admin_enqueue_scripts', 'my_admin_enqueue', 10 );

【讨论】:

    猜你喜欢
    • 2016-02-12
    • 1970-01-01
    • 2021-05-18
    • 2022-06-29
    • 2015-03-07
    • 2012-05-28
    • 2021-06-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多