Skip to content

Instantly share code, notes, and snippets.

@szbl
Created March 10, 2017 18:15
Show Gist options
  • Save szbl/d2fff5edcb6c5dc8cae01d7d26c5a77a to your computer and use it in GitHub Desktop.
Save szbl/d2fff5edcb6c5dc8cae01d7d26c5a77a to your computer and use it in GitHub Desktop.
Convert from HeadSpace2 to Yoast SEO quick.
<?php
/*
Adds Yoast SEO post meta for quick conversion for title/meta description
from HeadSpace2.
*/
add_action( 'init', 'szbl_convert' );
function szbl_convert()
{
if ( $_GET['seo-conversion'] == 1 )
{
echo '<div style="font:16px Helvetica,Arials,Sans-serif;">';
$posts = new WP_Query(array( 'post_type' => array( 'post', 'page' ), 'posts_per_page' => 999 ) );
while ( $posts->have_posts() )
{
$posts->the_post();
$title = get_post_meta( get_the_ID(), '_headspace_page_title', true );
$description = get_post_meta( get_the_ID(), '_headspace_description', true );
update_post_meta( get_the_ID(), '_yoast_wpseo_title', $title );
update_post_meta( get_the_ID(), '_yoast_wpseo_metadesc', $description );
echo '<h1>' . get_the_title() . '</h1>';
echo '<h3>' . $title . '</h3>';
echo '<p><em>' . $description . '</em></p>';
echo '<hr>';
}
echo '</div>';
die;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment