I want to be able to share parts of a page using a URL parameter like ?jumpto=quoteoftheday and based on that URL parameter, the social share information would be different for Facebook and Twitter. I am already pulling the URL parameter fine, I just need to know if it’s possible to override just the social media tags in the header somehow.
Is there a hook I can use in my functions file to override the social media tags for the header?
I use Yoast SEO. I don’t know if that complicates things. I just want to be able to replace that block of social media tags in the header with my own. Specifically for Facebook and Twitter.
Thanks in advance!
Hello,
I’m not sure it can be overwritten from the functions file, but the code for the social icons you can try to alter this code:
https://www.screencast.com/t/mIf0sASlnFm
Thanks
Hey Bogdan, thanks for the reply!
I don’t want to edit the social buttons themselves. I need to change the social sharing meta information in the <head> of the page. All this stuff:
<meta property="og:locale" content="en_US" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Your source for progressive news and activism" />
<meta property="og:description" content="NationofChange is a 501(c)3 nonprofit news and activism organization with no corporate owners and a mission to enact progressive change through positive action." />
<meta property="og:url" content="https://dev.nationofchange.org/" />
<meta property="og:site_name" content="NationofChange" />
<meta property="og:image" content="https://dev.nationofchange.org/wp-content/uploads/2016/09/fbsharelogo-1.png" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="NationofChange | Progressive News and Activism - NationofChange" />
<meta name="twitter:site" content="@NationofChange" />
<meta name="twitter:image" content="https://dev.nationofchange.org/wp-content/uploads/2017/06/occupybanner.jpg" />
<meta name="twitter:creator" content="@NationofChange" />
I want to override that to be custom information. I will use a parameter in the URL like ?jumpto=quoteoftheday and based on that info, I need to change that meta info. Is this possible?
Hello,
I understand now, but the meta fields you mention are not added by our theme. They are added by seo yoast. Unfortunately there is no solution we can provide in this regard as we have not tested any such implementation. You will have to search for a yoast solution online or hire a freelancer to help out with the customization.
Thank you!
Ok, thank you for the reply. I looked into this and was able to get it working using wpseo filters like this (if anyone is interested):
function filter_wpseo_title($title) {
$title = 'My Super Title';
return $title;
}
add_filter('wpseo_title', 'filter_wpseo_title');