Last active
July 27, 2020 14:50
-
-
Save jchristopher/7c908aa998e63e2c72648a1a2102b0e7 to your computer and use it in GitHub Desktop.
Outputting SearchWP results that are Gravity Forms Entries
This file contains 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 | |
$searchwp = new \SearchWP\Query( 'marketing', [ | |
'engine' => 'gravity', | |
'fields' => 'all', | |
] ); | |
foreach ( $searchwp->results as $result ) { | |
switch ( get_class( $result ) ) { | |
case 'SearchWP\Sources\GravityForms\Entry': | |
// NOTE: Gravity Forms Field values are keyed by the Field ID in the Form editor. | |
?> | |
<div class="result"> | |
Form ID: <?php echo esc_html( $result->id ); ?><br> | |
Name: <?php echo esc_html( $result->{'1'} ); ?><br> | |
Email: <?php echo esc_html( $result->{'2'} ); ?><br> | |
Type: <?php echo esc_html( $result->{'3'} ); ?><br> | |
Feature: <?php echo esc_html( $result->{'4'} ); ?> | |
</div> | |
<?php | |
break; | |
default: | |
// Another Source was added to the SearchWP Engine. | |
print_r( $result ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment