Php 以内联方式显示Wordpress排队样式css文件?

Php 以内联方式显示Wordpress排队样式css文件?,php,wordpress,amp-html,Php,Wordpress,Amp Html,大家好,我有一个Wordpress网站,我想把它转换成一个AMP网站,其中一个挑战性的任务是在内联中重写css 所以在wordpress框架中,我们有这个functions.php文件,里面有函数 /** * Proper way to enqueue scripts and styles */ function wpdocs_mytheme_styles() { wp_enqueue_style( 'style', get_stylesheet_uri() . '/css/style.cs

大家好,我有一个Wordpress网站,我想把它转换成一个AMP网站,其中一个挑战性的任务是在内联中重写css

所以在wordpress框架中,我们有这个functions.php文件,里面有函数

/**
* Proper way to enqueue scripts and styles
*/
function wpdocs_mytheme_styles() {
  wp_enqueue_style( 'style', get_stylesheet_uri() . '/css/style.css' );}

  add_action( 'wp_enqueue_scripts', 'wpdocs_mytheme_styles' );
基本上Wordpress会在前端页面上给我们这一行

<link rel='stylesheet' id='style'  href='Path_to/css/stle.css' type='text/css' media='all' />

我是否可以更改此显示机制,使Wordpress以**内联方式显示注册的样式**

<style amp-custom>
<!-- The content of the style.css -->
<!-- .... -->

</style>


是的,基本上我有很多这样的文件,我不想通过打开每个文件并在标题中复制/粘贴内容来进行静态更改。有什么想法吗?

你想使用内联样式吗?

你想使用内联样式吗?

你需要添加样式吗使用wp_head()直接到页眉

add_action('wp_head','my_custom_style',100);
函数my_自定义_样式()
{
回声“*{color:red}”;
}

您需要使用wp_head()将样式直接添加到页面标题

add_action('wp_head','my_custom_style',100);
函数my_自定义_样式()
{
回声“*{color:red}”;
}

您可以这样做:

<style amp-custom>
  {% include "/assets/css/main.min.css" %}
 </style>

{%include”/assets/css/main.min.css“%}
或者


/*任何自定义样式都可以在这里使用*/
身体{
背景色:白色;
}
amp-img{
边框:5px纯黑;
}
amp-img.GRY-placeholder{
背景颜色:灰色;
}

参考

您可以这样做:

<style amp-custom>
  {% include "/assets/css/main.min.css" %}
 </style>

{%include”/assets/css/main.min.css“%}
或者


/*任何自定义样式都可以在这里使用*/
身体{
背景色:白色;
}
amp-img{
边框:5px纯黑;
}
amp-img.GRY-placeholder{
背景颜色:灰色;
}

参考

你好,是的,我想做一个需要内联样式的AMP网站你好,是的,我想做一个需要内联样式的AMP网站是的,我发现了一个函数wp_add_inline_style,可以很有趣地查找是的,你也可以使用它()嗨@Krishna Savani是的,我设法做了一些自动内联,但我遇到了麻烦,因为有一个最大大小的css,你可以在AMP中内联,所以我现在正在尝试为AMP页面做一些自定义css,谢谢你,再次感谢你,是的,我发现了一个函数wp_add_inline_style,可以很有趣地查找是的,你也可以使用它()嗨@Krishna Savani是的,我设法做了一些自动内联,但我遇到了麻烦,因为有一个最大大小的css,你可以内联在AMP中,所以我正在尝试为AMP页面做一些自定义css,谢谢你现在正在使用哪个AMP插件?嗨,Sami Ahmed,我正在使用这个带有过渡模式的插件,所以我有我的经典网站和一个以amp为amp版本完成的网站。你使用的是哪个amp插件?嗨,萨米·艾哈迈德,我用的是过渡模式的插件,所以我有我的经典网站和一个以amp为amp版本完成的网站。
<style amp-custom>
      /* any custom styles go here. */
      body {
        background-color: white;
      }
      amp-img {
        border: 5px solid black;
      }
      amp-img.grey-placeholder {
        background-color: grey;
      }
    </style>