I wanted to get the Yoast SEO generated data manually, see example code below
This data is being generated by Yoast and automatically add it inside the head tag.
<!-- This site is optimized with the Yoast SEO plugin v4.2.1 - https://yoast.com/wordpress/plugins/seo/ -->
<meta name="description" content="bla bla bla"/>
<meta name="robots" content="noodp"/>
<link rel="canonical" href="http://example.localhost.com/" />
<meta property="og:locale" content="en_US" />
<meta property="og:type" content="website" />
<meta property="og:title" content="bla bla bla" />
<meta property="og:url" content="http://example.localhost.com/" />
<meta property="og:site_name" content="Example.com" />
<meta property="og:image" content="http://example.com.au/wp-content/uploads/2016/11/example.png" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:description" content="bla bla bla." />
<meta name="twitter:title" content="bla bla bla" />
<meta name="twitter:image" content="http://example.com.au/wp-content/uploads/2016/11/example.png" />
<script type='application/ld+json'>{"@context":"http:\/\/schema.org","@type":"WebSite","@id":"#website","url":"http:\/\/example.localhost.com\/","name":"Example","potentialAction":{"@type":"SearchAction","target":"http:\/\/example.localhost.com\/?s={search_term_string}","query-input":"required name=search_term_string"}}</script>
<!-- / Yoast SEO plugin. -->
I do not want to use wp_head(); because it also generates other scripts, styles and whatever plugin or code you have in your wordpress website.
I do not need all those codes. I only want to get the Yoast SEO generated code as shown above. any ideas how could i do that?
You can get the yoast meta in any page by get_post_meta()
,
get the meta values by following,
echo get_post_meta(get_the_ID(), '_yoast_wpseo_metadesc', true);
echo get_post_meta(get_the_ID(), '_yoast_wpseo_title', true);
Check the post_meta
table to get all the values related to each page/post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With