Pass variable in wpseo_opengraph_image filter
-
Hi there,
I was wundering if there is a way to pass an ‘image’ variable in the wpseo_opengraph_image filter?
I have several post type archives with no featured images, and in those archive templates I would like to set an image variable which should be used within the function being called in the wpseo_opengraph_image filter.I tried setting a global variable like discussed here, but that doesn’t work.
My code:
global $share_img; $share_img = 'some-image.jpg'; function custom_og_image() { global $share_img; return $share_img; } add_filter('wpseo_opengraph_image', 'custom_og_image');
Any ideas?
- The topic ‘Pass variable in wpseo_opengraph_image filter’ is closed to new replies.