Last active
September 8, 2025 20:26
-
-
Save jakebellacera/c2aab8f786a0617b27dd4914c70463d4 to your computer and use it in GitHub Desktop.
Revisions
-
jakebellacera revised this gist
Apr 23, 2020 . 1 changed file with 1 addition and 0 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 @@ -2,6 +2,7 @@ /** * Plugin Name: Disable Yoast SEO Automatic Open Graph Images * Plugin URI: https://gist.github.com/jakebellacera/c2aab8f786a0617b27dd4914c70463d4 * Description: Shows the default open graph image in case a feature image isn't set, rather than showing a random image on the page. * Version: 0.0.0 * Author: Jake Bellacera -
jakebellacera created this gist
Apr 23, 2020 .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,26 @@ <?php /** * Plugin Name: Disable Yoast SEO Automatic Open Graph Images * Description: Shows the default open graph image in case a feature image isn't set, rather than showing a random image on the page. * Version: 0.0.0 * Author: Jake Bellacera * Author URI: https://www.jakebellacera.com/ */ /** * Force default open graph images in case feature image isn't set */ add_filter('wpseo_add_opengraph_images', 'jb_force_default_open_graph_image', 10, 1); function jb_force_default_open_graph_image($images) { if (!has_post_thumbnail() && WPSEO_Options) { $default_id = WPSEO_Options::get('og_default_image_id', ''); if ($default_id) { $images->add_image_by_id($default_id); } } return $images; }