So I’m getting it to update the correct meta fields when creating a new entry, but it’s not reading the fields to put in there. Here is my function:
function update_yoast( $post_id ) {
$focuskw = '_yoast_wpseo_focuskw';
$title = '_yoast_wpseo_title';
$metadesc = '_yoast_wpseo_metadesc';
$jobtitle = get_post_meta( $post_ID, '_job_title', true );
$city = get_post_meta( $post_ID, 'geolocation_city', true );
$shortstate = get_post_meta( $post_ID, 'geolocation_state_short', true );
$longstate = get_post_meta( $post_ID, 'geolocation_state_long', true );
update_post_meta($post_id, $focuskw, $jobtitle . ' in ' . $city . ', ' . $shortstate . ' - Darts Bar Databases');
update_post_meta($post_id, $title, 'Find hours, reviews, and info on ' . $jobtitle . ' and the best ' . $city . ', ' . $longstate . ' bars. Discover nearby darts leagues and tournaments.');
update_post_meta($post_id, $metadesc, $jobtitle . ' in ' . $city . ', ' . $shortstate);
}
add_action( 'save_post', 'update_yoast' );
Is get_post_meta
not the correct function to use?