{"id":2113,"date":"2022-05-18T15:29:53","date_gmt":"2022-05-18T13:29:53","guid":{"rendered":"https:\/\/www.wp-moon.com\/?p=2113"},"modified":"2022-05-18T15:29:55","modified_gmt":"2022-05-18T13:29:55","slug":"yoast-seo-update-programmatically-metas","status":"publish","type":"post","link":"https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/","title":{"rendered":"How to update the Yoast SEO title and description programmatically"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">You can easily put custom metas into your code thanks to the plugin <strong>Yoast SEO<\/strong>: <strong>meta title<\/strong> and <strong>meta description<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There is no problem if you want to edit it manually but you <strong>can&#8217;t do it through Yoast SEO API<\/strong>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The good news is that Yoast SEO uses classical <strong>WordPress post meta<\/strong> to store values. So you can update it like any post meta.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is an example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>update_post_meta( $id, '_yoast_wpseo_metadesc', 'My post description' );\r\nupdate_post_meta( $id, '_yoast_wpseo_title', 'My post title' );<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Change the <em>$id<\/em> by your post id and your post will be <strong>automatically updated<\/strong>! nothing else to do.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you <a href=\"https:\/\/www.wp-moon.com\/create-posts-pages-programmatically\/\">create a post programmatically<\/a>, you can include the code above just after the wp_insert_post() function.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can easily put custom metas into your code thanks to the plugin Yoast SEO: meta title and meta description. There is no problem if you want to edit it manually but you can&#8217;t do it through Yoast SEO API. The good news is that Yoast SEO uses classical WordPress post meta to store values. &hellip; <a href=\"https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to update the Yoast SEO title and description programmatically<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":1794,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[147],"tags":[],"class_list":["post-2113","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to update the Yoast SEO title and description programmatically - WP Moon<\/title>\n<meta name=\"description\" content=\"You can easily put custom metas into your code thanks to the plugin Yoast SEO: meta title and meta description. There is no problem if you want to edit it\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to update the Yoast SEO title and description programmatically - WP Moon\" \/>\n<meta property=\"og:description\" content=\"You can easily put custom metas into your code thanks to the plugin Yoast SEO: meta title and meta description. There is no problem if you want to edit it\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/\" \/>\n<meta property=\"og:site_name\" content=\"WP Moon\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/wpmoonwebsite\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-18T13:29:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-05-18T13:29:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2020\/06\/logo-yoast.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"561\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Alexandre G\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@alexgaboriau\" \/>\n<meta name=\"twitter:site\" content=\"@WPMoon4\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alexandre G\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to update the Yoast SEO title and description programmatically - WP Moon","description":"You can easily put custom metas into your code thanks to the plugin Yoast SEO: meta title and meta description. There is no problem if you want to edit it","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/","og_locale":"en_US","og_type":"article","og_title":"How to update the Yoast SEO title and description programmatically - WP Moon","og_description":"You can easily put custom metas into your code thanks to the plugin Yoast SEO: meta title and meta description. There is no problem if you want to edit it","og_url":"https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/","og_site_name":"WP Moon","article_publisher":"https:\/\/www.facebook.com\/wpmoonwebsite","article_published_time":"2022-05-18T13:29:53+00:00","article_modified_time":"2022-05-18T13:29:55+00:00","og_image":[{"width":1024,"height":561,"url":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2020\/06\/logo-yoast.jpg","type":"image\/jpeg"}],"author":"Alexandre G","twitter_card":"summary_large_image","twitter_creator":"@alexgaboriau","twitter_site":"@WPMoon4","twitter_misc":{"Written by":"Alexandre G","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/#article","isPartOf":{"@id":"https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/"},"author":{"name":"Alexandre G","@id":"https:\/\/www.wp-moon.com\/en\/#\/schema\/person\/72a64e6910977ec9e4b32fd8da54369d"},"headline":"How to update the Yoast SEO title and description programmatically","datePublished":"2022-05-18T13:29:53+00:00","dateModified":"2022-05-18T13:29:55+00:00","mainEntityOfPage":{"@id":"https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/"},"wordCount":116,"commentCount":0,"publisher":{"@id":"https:\/\/www.wp-moon.com\/en\/#organization"},"image":{"@id":"https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2020\/06\/logo-yoast.jpg","articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/","url":"https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/","name":"How to update the Yoast SEO title and description programmatically - WP Moon","isPartOf":{"@id":"https:\/\/www.wp-moon.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/#primaryimage"},"image":{"@id":"https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2020\/06\/logo-yoast.jpg","datePublished":"2022-05-18T13:29:53+00:00","dateModified":"2022-05-18T13:29:55+00:00","description":"You can easily put custom metas into your code thanks to the plugin Yoast SEO: meta title and meta description. There is no problem if you want to edit it","breadcrumb":{"@id":"https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/#primaryimage","url":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2020\/06\/logo-yoast.jpg","contentUrl":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2020\/06\/logo-yoast.jpg","width":1024,"height":561,"caption":"Yoast SEO"},{"@type":"BreadcrumbList","@id":"https:\/\/www.wp-moon.com\/en\/yoast-seo-update-programmatically-metas\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.wp-moon.com\/en\/"},{"@type":"ListItem","position":2,"name":"Tutorials","item":"https:\/\/www.wp-moon.com\/en\/category\/tutorials\/"},{"@type":"ListItem","position":3,"name":"How to update the Yoast SEO title and description programmatically"}]},{"@type":"WebSite","@id":"https:\/\/www.wp-moon.com\/en\/#website","url":"https:\/\/www.wp-moon.com\/en\/","name":"WP Moon","description":"","publisher":{"@id":"https:\/\/www.wp-moon.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wp-moon.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.wp-moon.com\/en\/#organization","name":"WP Moon","url":"https:\/\/www.wp-moon.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wp-moon.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2020\/02\/logo.png","contentUrl":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2020\/02\/logo.png","width":290,"height":95,"caption":"WP Moon"},"image":{"@id":"https:\/\/www.wp-moon.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/wpmoonwebsite","https:\/\/x.com\/WPMoon4"]},{"@type":"Person","@id":"https:\/\/www.wp-moon.com\/en\/#\/schema\/person\/72a64e6910977ec9e4b32fd8da54369d","name":"Alexandre G","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2023\/09\/312419460_10229483707296045_2919774527885824513_n-100x100.jpg","url":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2023\/09\/312419460_10229483707296045_2919774527885824513_n-100x100.jpg","contentUrl":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2023\/09\/312419460_10229483707296045_2919774527885824513_n-100x100.jpg","caption":"Alexandre G"},"description":"Alexandre, Web Developer &amp; Website Editor. I've been using WordPress for over 10 years in my professional environment and on personal projects. I created WP Moon to teach you how to use this CMS, solve your problems and show you all the tricks.","sameAs":["https:\/\/www.croque-pixel.com\/","https:\/\/x.com\/alexgaboriau","https:\/\/www.youtube.com\/@wp_moon\/videos"],"url":"https:\/\/www.wp-moon.com\/en\/author\/wp-moon\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/posts\/2113","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/comments?post=2113"}],"version-history":[{"count":0,"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/posts\/2113\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/media\/1794"}],"wp:attachment":[{"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/media?parent=2113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/categories?post=2113"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/tags?post=2113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}