wordpress block theme 添加自定义css

分享讨论IT相关的内容
回复
头像
BobMaster
锋芒初露
锋芒初露
帖子: 1187
注册时间: 2020年 12月 7日 08:05
来自: 神秘的东方
我的状态: 🎯
为圈友点赞: 338 次
被赞次数: 178 次
联系:

wordpress block theme 添加自定义css

帖子 BobMaster »

wordpress从版本5.9开始支持block theme,你可以使用各种区块构建自己的主题。

这篇帖子记录一下如何添加自定义css。
在主题目录下新建functions.php,内容如下

代码: 全选

<?php

if ( ! function_exists( 'qianxue_styles' ) ) :

    /**
     * Enqueue styles.
     */
    function qianxue_styles() {
            // Register theme stylesheet.
            $theme_version = wp_get_theme()->get( 'Version' );

            $version_string = is_string( $theme_version ) ? $theme_version : false;
            wp_register_style(
                    'qianxue-style',
                    get_template_directory_uri() . '/style.css',
                    array(),
                    $version_string
            );

            // Enqueue theme stylesheet.
            wp_enqueue_style( 'qianxue-style' );

    }

endif;

add_action( 'wp_enqueue_scripts', 'qianxue_styles' );

// Enqueue stylesheet in Editor
function qianxue_theme_setup() {
    add_editor_style( 'style.css' );
}
add_action( 'after_setup_theme', 'qianxue_theme_setup' );
函数名称可以改为你想要的。

参考链接: https://www.youtube.com/watch?v=Xz7uo1cFma0
人生如音乐,欢乐且自由
头像
ejsoon
圈圈精英
圈圈精英
帖子: 2180
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 96 次
被赞次数: 92 次
联系:

Re: wordpress block theme 添加自定义css

帖子 ejsoon »

https://ejsoon.win/
天蒼人頡:發掘好玩事物
回复
  • 猜你喜欢
    回复总数
    阅读次数
    最新帖子

在线用户

正浏览此版面之用户: 没有注册用户 和 3 访客