Skip to content

Instantly share code, notes, and snippets.

@moskalukigor
Last active December 16, 2022 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moskalukigor/41e51b675fd4bea2f90dabf76e365a12 to your computer and use it in GitHub Desktop.
Save moskalukigor/41e51b675fd4bea2f90dabf76e365a12 to your computer and use it in GitHub Desktop.
update YoastSEO title and description with qTranslate
<?php
add_action('wp', function(){
global $wpdb;
$seo_title = "[:uk]TEST TITLE😜[:en]TEST TITLE😜[:]";
$seo_description = "[:uk]Test description 👍[:en]Test description 👍[:]";
$sql = "SELECT option_value FROM wp_options WHERE option_name = 'wpseo_taxonomy_meta'";
$result = $wpdb->get_results($sql);
$result = $result[0]->option_value;
$result = unserialize($result);
//Where post_tag = $taxonomy & 123 = term_id
$result['post_tag'][123]['wpseo_title'] = $seo_title;
$result['post_tag'][123]['wpseo_desc'] = $seo_description;
$result = serialize($result);
$sql = "UPDATE wp_options SET option_value = '".$result."' WHERE option_name = 'wpseo_taxonomy_meta'";
$wpdb->query($sql);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment