Skip to content

Instantly share code, notes, and snippets.

@amboutwe
Last active December 3, 2023 09:01
Show Gist options
  • Save amboutwe/5c2d716cfe650b2eaeec8de1b8213368 to your computer and use it in GitHub Desktop.
Save amboutwe/5c2d716cfe650b2eaeec8de1b8213368 to your computer and use it in GitHub Desktop.
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Sync post meta to Yoast Indexable
* Credit: Yoast team
* Last Tested: Dec 20 2022 using Yoast SEO 19.13 on WordPress 6.1.1
*/
// The ID of the post to modify
$post_id = 1;
// The post meta to modify
update_post_meta( $post_id, $key = '_yoast_wpseo_focuskw', $value = 'Custom focus keyphrase' );
update_post_meta( $post_id, $key = '_yoast_wpseo_metadesc', $value = 'Custom description' );
update_post_meta( $post_id, $key = '_yoast_wpseo_title', $value = 'Custom title' );
// Update post to sync from post meta to yoast indexable
$my_post = array(
'ID' => $post_id
);
wp_update_post( $my_post );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment