Last active
November 19, 2023 11:56
-
-
Save atanemani/de371f7a50155bbe9456476bc20d5408 to your computer and use it in GitHub Desktop.
How to Convert or Change Post Types in WordPress
This file contains hidden or 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 | |
$transformable_posts = get_posts([ | |
'post_type' => ['microcontent', 'banner'], | |
'post_status' => ['publish', 'draft'], | |
'posts_per_page' => -1 | |
]); | |
if (!empty($transformable_posts)) { | |
foreach ($transformable_posts as $post) { | |
set_post_type($post->ID, 'content'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment