Instantly share code, notes, and snippets.

Embed
What would you like to do?
Programmatically Set Reading Settings in WP Admin
<?php
/**
* Update WordPress Reading Settings Programmatically.
*
* @author Edwin Velez
* @see https://edwinvelez.net/programmatically-set-reading-settings-in-wp-admin/
*/
// Set static front page.
$home_page = get_page_by_title('Home');
update_option('page_on_front', $home_page->ID);
update_option('show_on_front', 'page');
// Set blog page.
$blog_page = get_page_by_title('Blog');
update_option('page_for_posts', $blog_page->ID);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment