Created
November 20, 2025 10:04
-
-
Save dmje/5e69a74a0ffb043c8f1a17dec2df8a55 to your computer and use it in GitHub Desktop.
This one seems to work. Example deployed to MoDA on 24/09/20. See link to Gist below for other examples.
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 | |
| // Change OG image for single objects | |
| // Based on snippet here https://gist.github.com/amboutwe/811e92b11e5277977047d44ea81ee9d4 | |
| add_filter( 'wpseo_opengraph_image', 'change_opengraph_image_url' ); | |
| function change_opengraph_image_url( $url ) | |
| { | |
| if(is_singular( 'object' )) | |
| { | |
| $seo_image = cos_get_field('image'); | |
| $seo_image = str_replace('v0_web.jpg', 'v0_high.jpg', $seo_image); | |
| return $seo_image; | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment