Created
May 18, 2026 12:51
-
-
Save damiencarbery/fe6483741d7dd8501ba3e853332ab0b4 to your computer and use it in GitHub Desktop.
Add fields to event JSON+LD to fix warnings from Google Search Console.
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 | |
| // Add fields to event JSON+LD to fix warnings from Google Search Console. | |
| add_filter( 'tribe_json_ld_event_object', 'ccs_add_data_to_json_ld', 10, 2 ); | |
| function ccs_add_data_to_json_ld( $data, $args ) { | |
| $fields = array( 'location', 'organizer', 'image', 'offers', 'description' ); | |
| foreach ( $fields as $field ) { | |
| if ( empty( $data->$field ) ) { | |
| $data->$field = ''; | |
| } | |
| } | |
| return $data; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment