Elementor 正在 WordPress 页面的头部部分生成页面特定的样式和脚本。有没有办法将它们读取到 GraphQL?
我分两步对 WpBakery pagebuilder 做了同样的事情:
使用编辑器中的 CSS 在 graphQL 中注册新字段,例如:
add_action( 'graphql_register_types', function() {
register_graphql_field( 'Page', 'customCSS', [
'type' => 'String',
'description' => __( 'Custom CSS from Editor', 'wp-graphql' ),
'resolve' => function() {
// call your function which return your custom css
return $this->addPageCustomCssToGraphql();
}
] );
} );
在 Gatsby 页面中请求它们,并使用 Helmet 插件在页面的 HEAD 中显示您的 CSS。
你把这个代码放在哪里? IIn主题的功能还是在哪里? 我找不到在哪里注册它来查询