Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rameshelamathi/3038268c05d6e96f749ed83f3591fe52 to your computer and use it in GitHub Desktop.
Save rameshelamathi/3038268c05d6e96f749ed83f3591fe52 to your computer and use it in GitHub Desktop.
Get Elementor built page content with CSS styles in WPGraphQL
add_action( 'graphql_register_types', function() {
$field_config = [
'type' => 'String',
'description' => __('Elementor rendered content', 'wp-graphql'),
'args' => [
'myArg' => [
'type' => 'String',
],
],
'resolve' => function( $page ) {
if (class_exists("\\Elementor\\Plugin")) {
$post_ID = $page->ID;
$pluginElementor = \Elementor\Plugin::instance();
$contentElementor = $pluginElementor->frontend->get_builder_content($post_ID, true);
}
return $contentElementor;
},
];
register_graphql_field( 'Page', 'elementorContent', $field_config);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment