Skip to content

Instantly share code, notes, and snippets.

@maheshwaghmare
Created July 3, 2018 11:34
Show Gist options
  • Save maheshwaghmare/b141623d1853424b7e56a792155f2501 to your computer and use it in GitHub Desktop.
Save maheshwaghmare/b141623d1853424b7e56a792155f2501 to your computer and use it in GitHub Desktop.
Update bulk post using wp_update_post().
<?php
$ids = array(18821,18811,18817,18805,18807,18777,18774,18775);
foreach ($ids as $key => $id) {
$my_post = array(
'ID' => $id,
'tax_input' => array(
'<taxonomy-name>' => array( `<tax-id1>`, `<tax-id2>`, `<tax-id-n` ),
),
);
// Update the post into the database
wp_update_post( $my_post );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment