xxxxxxxxxx
// Set page with ID 5 as the home page
update_option('page_on_front', 5);
update_option('show_on_front', 'page');
xxxxxxxxxx
<?php
// Change WordPress home page programmatically using page ID
update_option('page_on_front', 123); // Replace 123 with the desired page ID
// Optionally, you can also update the page's URL slug
update_option('show_on_front', 'page');
update_option('page_for_posts', 456); // Replace 456 with the desired page ID to set as the blog posts page