Created
February 28, 2018 13:20
-
-
Save staude/9fc0f013f6c9131e197273bff26283b7 to your computer and use it in GitHub Desktop.
materialpool old slug generate wpcli cmds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include "wp-load.php"; | |
$files = array( | |
'themenseiten-sammlung-1.xml', | |
'themenseiten-sammlung-2.xml', | |
'themenseiten-sammlung-3.xml', | |
); | |
foreach ( $files as $file ) { | |
$doc = new DOMDocument(); | |
$doc->load($file); | |
$items = $doc->getElementsByTagName("item"); | |
foreach ($items as $item) { | |
$titel = ''; | |
$id = ''; | |
$oldslug = ''; | |
foreach ( $item->childNodes as $child ) { | |
if ( $child->tagName ) { | |
if ( $child->tagName == "title") { | |
$titel = $child->nodeValue; | |
} | |
if ( $child->tagName == "wp:postmeta") { | |
$value = $child->nodeValue; | |
$pos = strpos( $value, '/tagpage/' ); | |
if ( $pos !== false ) { | |
$oldslug = trim ( substr( $value ,$pos ) ); | |
} | |
} | |
} | |
} | |
$page = get_page_by_title( $titel, "OBJECT", 'material' ); | |
if ( $page != null ) { | |
$id = $page->ID; | |
if ( $id != '' && $titel != "" && $oldslug != "" ) { | |
?> | |
wp post meta set <?php echo $id; ?> old_slug <?php echo $oldslug; ?> <br> | |
<?php | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment