----------------------------------
add_action('admin_init', 'quick_replace_amazon_tag');
function quick_replace_amazon_tag() {
// This code will run only when you click on the link.
if ( isset($_GET['replace_amazon_tags']) && $_GET['replace_amazon_tags'] == 'yes' ) {
global $wpdb;
$old_tag = 'oldtag-20'; // Enter your current (old) tag here.
$new_tag = 'newtag-20'; // Enter your new tag here.
// Will replace the post_content column in the database
$wpdb->query(
$wpdb->prepare(
"UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, %s, %s)",
$old_tag,
$new_tag
)
);
// A success message will be displayed.
add_action('admin_notices', function() {
echo '<div class="notice notice-success is-dismissible"><p><strong>Success!</strong> Amazon Affiliate tags replaced successfully in all posts.</p></div>';
});
}
}
---------------------------------------------------
https://yourdomain.com/wp-admin/?replace_amazon_tags=yes
----------------------------------------------------
No comments:
Post a Comment