Skip to content

Instantly share code, notes, and snippets.

@lukeawyatt
Last active January 8, 2021 20:25
Show Gist options
  • Save lukeawyatt/70d02e86707b2a39b3968702ebbee7d4 to your computer and use it in GitHub Desktop.
Save lukeawyatt/70d02e86707b2a39b3968702ebbee7d4 to your computer and use it in GitHub Desktop.
Application: WordPress
<?php /** INCLUDE IN FUNCTIONS.PHP **/
function set_metadata() {
global $post;
$title = get_post_meta($post->ID, MetaTitle, true);
$keywords = get_post_meta($post->ID, MetaKeywords, true);
$description = get_post_meta($post->ID, MetaDescription, true);
if (!is_home() || !is_front_page()) {
if (!empty($title)) {
echo '<meta name="title" content="' . $title . '" />';
}
if (!empty($keywords)) {
echo '<meta name="keywords" content="' . $keywords . '" />';
}
if (!empty($description)) {
echo '<meta name="description" content="' . $description . '" />';
}
}
echo $metatag;
}
add_action('wp_head', 'set_metadata');
?>
UPDATE `wp_posts`
SET `post_content` = REPLACE(`post_content`, "http://oldurl.com", "https://newurl.com");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment