-
-
Save searchwpgists/35a7cdd8df9eeb39787f9170ce46d650 to your computer and use it in GitHub Desktop.
Index post content built with the Elementor Builder
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
| <?php | |
| // Index post content built with the Elementor Builder | |
| add_filter( 'searchwp\source\post\attributes\content', function( $content, $args ) { | |
| if ( class_exists('\Elementor\Plugin' ) ) { | |
| // We don't want CSS code on the post content while indexing. | |
| add_filter( 'elementor/frontend/builder_content/before_print_css', '__return_false' ); | |
| $elementor = new \Elementor\Frontend(); | |
| $content = $elementor->get_builder_content_for_display( $args['post']->ID ); | |
| // Remove the filter once we have grabbed the content. | |
| remove_filter( 'elementor/frontend/builder_content/before_print_css', '__return_false' ); | |
| } | |
| return $content; | |
| }, 20, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment