Skip to content

Instantly share code, notes, and snippets.

@mkormendy
Forked from jsoningram/export-yoast-redirects.php
Last active April 9, 2024 20:18
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 mkormendy/ff54af5407ea67a48d2337fe8db9410b to your computer and use it in GitHub Desktop.
Save mkormendy/ff54af5407ea67a48d2337fe8db9410b to your computer and use it in GitHub Desktop.
Export Yoast redirects to CSV file
<?php
$array_base = get_option('wpseo-premium-redirects-base');
foreach ( $array_base as $key => $row ) {
file_put_contents( ABSPATH . 'yoast-redirects-base.csv', $key . ',' . $row[ 'url' ] . "\n", FILE_APPEND );
}
$array_plain = get_option('wpseo-premium-redirects-export-plain');
foreach ( $array_plain as $key => $row ) {
file_put_contents( ABSPATH . 'yoast-redirects-export-plain.csv', $key . ',' . $row[ 'url' ] . "\n", FILE_APPEND );
}
$array_regex = get_option('wpseo-premium-redirects-export-regex');
foreach ( $array_regex as $key => $row ) {
file_put_contents( ABSPATH . 'yoast-redirects-export-regex.csv', $key . ',' . $row[ 'url' ] . "\n", FILE_APPEND );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment