{"id":216,"date":"2016-09-21T18:59:38","date_gmt":"2016-09-21T18:59:38","guid":{"rendered":"http:\/\/www.3pixls.com\/blog\/?p=216"},"modified":"2016-09-21T18:59:38","modified_gmt":"2016-09-21T18:59:38","slug":"automatically-create-meta-description-from-the_content","status":"publish","type":"post","link":"https:\/\/www.3pixls.com\/blog\/automatically-create-meta-description-from-the_content\/","title":{"rendered":"Automatically create meta description from the_content"},"content":{"rendered":"<p>Adding this snippet to the functions.php of your wordpress theme will automatically create a meta description from your wordpress post striping out all shortcodes and tags. Make sure you have in the header.php of your wordpress theme or this snippet will not work.<br \/>\n[php]<br \/>\nfunction create_meta_desc() {<br \/>\n  global $post;<br \/>\n  if (!is_single()) { return; }<br \/>\n  $meta = strip_tags($post-&gt;post_content);<br \/>\n  $meta = strip_shortcodes($post-&gt;post_content);<br \/>\n  $meta = str_replace(array(&quot;\\n&quot;, &quot;\\r&quot;, &quot;\\t&quot;), &#8216; &#8216;, $meta);<br \/>\n  $meta = substr($meta, 0, 125);<br \/>\n  echo &quot;&lt;meta name=&#8217;description&#8217; content=&#8217;$meta&#8217; \/&gt;&quot;;<br \/>\n}<br \/>\nadd_action(&#8216;wp_head&#8217;, &#8216;create_meta_desc&#8217;);<br \/>\n[\/php]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Adding this snippet to the functions.php of your wordpress theme will automatically create a meta description from your wordpress post striping out all shortcodes and tags. Make sure you have in the header.php of your wordpress theme or this snippet will not work. [php] function create_meta_desc() { global $post; if (!is_single()) { return; } $meta [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8,9],"tags":[],"_links":{"self":[{"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/posts\/216"}],"collection":[{"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/comments?post=216"}],"version-history":[{"count":1,"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/posts\/216\/revisions"}],"predecessor-version":[{"id":217,"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/posts\/216\/revisions\/217"}],"wp:attachment":[{"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/media?parent=216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/categories?post=216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/tags?post=216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}