Products
GG网络技术分享 2025-03-18 16:12 16
I\'m creating WordPress theme. But i faced with a interesting problem. So , I added a google font to Editor style. And It works correctly on localhost. Bu doesn\'t work on real host. Where can be problem ?
My Codes : # Editor Style support #add_theme_support( \'editor-styles\' );
# editor assets #
add_editor_style(get_template_directory_uri() .\'/style-editor.css\');
add_editor_style(\'https://fonts.googleapis.com/css?family=Poppins:400,500,700\');
add_editor_style(\'assets/css/font-awesome-4.css\');
图片转代码服务由CSDN问答提供
感谢您的意见,我们尽快改进~
功能建议我正在创建WordPress主题。 但我遇到了一个有趣的问题。 所以,我在编辑风格中添加了一个谷歌字体。 它在localhost上正常工作。 Bu不适用于真正的主机。 哪里可能有问题?
我的代码:</ p>
#Editor样式支持#add_theme_support(\'editor-styles\');
#editor assets#
add_editor_style(get_template_directory_uri ()。\'/ style-editor.css\');
add_editor_style(\'https://fonts.googleapis.com/css?family=Poppins:400,500,700\');
add_editor_style(\'assets / css / font-awesome -4.css\');
</ code> </ pre>
</ div>
网友观点:
UPDATED: Give this a try from the Wordpress Developer Documentation: https://developer.wordpress.org/reference/functions/add_editor_style/
Using Google Fonts
Google Fonts API provides a single URL for a CSS file that can include multiple variants of a type face, separated by commas. Commas in a URL need to be encoded before the string can be passed to add_editor_style.
/*** Registers an editor stylesheet for the current theme.
*/
function wpdocs_theme_add_editor_styles() {
$font_url = str_replace( \',\', \'%2C\', \'//fonts.googleapis.com/css?family=Lato:300,400,700\' );
add_editor_style( $font_url );
}
add_action( \'after_setup_theme\', \'wpdocs_theme_add_editor_styles\' );
Demand feedback