-
-
Save Camwyn/15e1936639a5ea7b1575b35f252ebd40 to your computer and use it in GitHub Desktop.
Revisions
-
Camwyn revised this gist
Jun 10, 2022 . 1 changed file with 7 additions and 12 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -18,12 +18,7 @@ */ function essgrid_post_based_featured_events_w_featured_image( $query, $grid_id ) { /* YOU MUST CHANGE THESE TO YOUR OWN SLIDER REVOLUTION SLIDER IDs!!! */ $grid_ids_to_affect = array( 1, 2, 14 ); // include IDs of grids to affect // if this grid is not one to affect, do no filtering @@ -35,27 +30,27 @@ function essgrid_post_based_featured_events_w_featured_image( $query, $grid_id ) if ( ! empty( $query['meta_query'] ) ) { $meta_query = (array) $query[ 'meta_query' ]; } else { $meta_query = []; } // do the filtering... // has a Featured Image $meta_query[] = array( 'compare' => 'BETWEEN', 'key' => '_thumbnail_id', 'value' => [ 1, PHP_INT_MAX ], ); // Restrict to events(posts) that have are featured events. if ( class_exists( 'Tribe__Events__Main' ) && class_exists( 'Tribe__Events__Featured_Events' ) && in_array( Tribe__Events__Main::POSTTYPE, (array) $query['post_type'] ) ) { $meta_query[] = [ 'compare' => 'EXISTS', 'key' => Tribe__Events__Featured_Events::FEATURED_EVENT_KEY, ]; } $query['meta_query'] = $meta_query; -
Camwyn revised this gist
Jun 10, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ * * essgrid_get_posts filter is from /wp-content/plugins/essential-grid/includes/base.class.php * * Tested working with version 6.5.24 * * Filter hook only applies to Essential Grid > Source > Source Based on Posts, Pages, Custom Posts * -
Camwyn revised this gist
Jun 9, 2022 . 1 changed file with 6 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,9 +4,9 @@ * * @link https://theeventscalendar.com/knowledgebase/featured-events/ * * Based on https://gist.github.com/cliffordp/a6aad3c60f469970b1ecb209d85ec755 * Similar code for Slider Revolution: https://gist.github.com/Camwyn/ce34677cafe52d46c12c11c8b9119371 * Same Essential Grid code except without requirement for being a Featured Event (works for more than just The Events Calendar): https://gist.github.com/Camwyn/cc191bc1c95581c38f7ed5f8ba61da11 * * essgrid_get_posts filter is from /wp-content/plugins/essential-grid/includes/base.class.php * @@ -43,13 +43,14 @@ function essgrid_post_based_featured_events_w_featured_image( $query, $grid_id ) // has a Featured Image $meta_query[] = array( 'key' => '_thumbnail_id', 'value' => [ 1, PHP_INT_MAX ], 'compare' => 'BETWEEN', ); // is a Featured Event (requires The Events Calendar version 4.4+ from January 9, 2017) if ( class_exists( 'Tribe__Events__Main' ) && class_exists( 'Tribe__Events__Featured_Events' ) && in_array( Tribe__Events__Main::POSTTYPE, (array) $query['post_type'] ) ) { $meta_query[] = array( 'key' => Tribe__Events__Featured_Events::FEATURED_EVENT_KEY, -
cliffordp revised this gist
Mar 15, 2017 . 1 changed file with 0 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -38,13 +38,6 @@ function essgrid_post_based_featured_events_w_featured_image( $query, $grid_id ) $meta_query = array(); } // do the filtering... // has a Featured Image -
cliffordp revised this gist
Mar 15, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,9 +4,9 @@ * * @link https://theeventscalendar.com/knowledgebase/featured-events/ * * From https://gist.github.com/cliffordp/a6aad3c60f469970b1ecb209d85ec755 * Similar code for Slider Revolution: https://gist.github.com/cliffordp/30ac2152a8264ef27235b46b7d16332d * Same Essential Grid code except without requirement for being a Featured Event (works for more than just The Events Calendar): https://gist.github.com/cliffordp/fbbaad70b9b8748819ac73f00260ac5e * * essgrid_get_posts filter is from /wp-content/plugins/essential-grid/includes/base.class.php * -
cliffordp created this gist
Mar 15, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,72 @@ <?php /** * Limit Essential Grid's WP_Query to only include Featured Events that have a featured image * * @link https://theeventscalendar.com/knowledgebase/featured-events/ * * From https://gist.github.com/cliffordp/ * Similar code for Slider Revolution: https://gist.github.com/cliffordp/30ac2152a8264ef27235b46b7d16332d * Same code except without requirement for being a Featured Event (works for more than just The Events Calendar): https://gist.github.com/cliffordp/fbbaad70b9b8748819ac73f00260ac5e * * essgrid_get_posts filter is from /wp-content/plugins/essential-grid/includes/base.class.php * * Tested working with version 2.1.0.2 * * Filter hook only applies to Essential Grid > Source > Source Based on Posts, Pages, Custom Posts * * @return array */ function essgrid_post_based_featured_events_w_featured_image( $query, $grid_id ) { /* * YOU MUST CHANGE THESE * TO YOUR OWN ESSENTIAL GRID * GRID IDs * !!! */ $grid_ids_to_affect = array( 1, 2, 14 ); // include IDs of grids to affect // if this grid is not one to affect, do no filtering if ( ! in_array( $grid_id, $grid_ids_to_affect ) ) { return $query; } // get the existing meta_query so we aren't wiping that out if ( ! empty( $query['meta_query'] ) ) { $meta_query = (array) $query[ 'meta_query' ]; } else { $meta_query = array(); } // get the existing meta_query so we aren't wiping that out if ( ! empty( $query['meta_query'] ) ) { $meta_query = (array) $query[ 'meta_query' ]; } else { $meta_query = array(); } // do the filtering... // has a Featured Image $meta_query[] = array( 'key' => '_thumbnail_id', 'compare' => 'EXISTS', ); // is a Featured Event (requires The Events Calendar version 4.4+ from January 9, 2017) if ( class_exists( 'Tribe__Events__Main' ) && class_exists( 'Tribe__Events__Featured_Events' ) && Tribe__Events__Main::POSTTYPE === $query['post_type'] ) { $meta_query[] = array( 'key' => Tribe__Events__Featured_Events::FEATURED_EVENT_KEY, 'compare' => 'EXISTS', ); } $query['meta_query'] = $meta_query; return $query; } add_filter( 'essgrid_get_posts', 'essgrid_post_based_featured_events_w_featured_image', 10, 2 );