admin管理员组文章数量:1125742
My hosting company upgraded my remote Wordpress version of my site to 6.4.2 and as I mentioned in a previous ticket alot of things stopped working. One item that seems to be broken are the custom styles I have in my Wordpress theme to overwrite editor styles in the CMS. I used to load my theme CSS in the editor the following way in my functions.php file:
function add_support() {
add_theme_support('menus');
add_theme_support('wp-block-styles');
add_theme_support('post-thumbnails');
add_theme_support('title-tag');
add_theme_support('responsive-embeds');
add_theme_support('custom-logo');
// load custom css for editor
add_editor_style(get_template_directory_uri() . '/assets/css/style.css');
add_editor_style(get_template_directory_uri() . '/assets/css/editor-styles.css');
add_theme_support('editor-styles');
}
add_action('after_setup_theme', 'add_support');
Okay, after reading some questions here I decided to change where the support was loaded by adding an action after the 'admin_init' event and I removed the add_editor_style
& add_theme_support
in the add_support
function. I added the following function to my functions.php file
function child_editor_styles() {
add_theme_support('editor-styles');
add_editor_style( [
get_template_directory_uri() . '/assets/css/style.css',
get_template_directory_uri() . '/assets/css/editor-styles.css'
] );
}
add_action('admin_init', 'child_editor_styles');
This doesn't overwrite or seem to add the CSS to the editor of my hosted wordpress version. I have a local MAMP Wordpress on my local machine to develop and experiment with code. Both versions of Wordpress, hosted and local are using Wordpress 6.4.2. Both have a PHP version of 8 with the hosted version having PHP 8 and local being 8.2. Both of the above functions load the css files in my local Wordpress version, neither seem to work on the hosted. I have checked that the file path for the CSS is correct on the hosted and it is? I am baffeled why this no longer seems to work on my hosted version but works on my local. I have checked file paths, css selectors and all is correct. The CSS files just don't seem to be loaded on the remote hosted version? Can anyone give me some ideas on how to resolve this issue?
本文标签:
版权声明:本文标题:theme development - Wordpress 6.4.2 - can't load editor style css using 'after_setup_theme' or ' 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736673772a1947065.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论