Created
May 25, 2021 16:25
-
-
Save rameshelamathi/3038268c05d6e96f749ed83f3591fe52 to your computer and use it in GitHub Desktop.
Get Elementor built page content with CSS styles in WPGraphQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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