I am in process to create my first wordpress theme with underscores.me skeleton, the theme i would like to create its a business theme so when my theme is activated to land directly to a static front-page instead of the default wp posts. How could i do this programmatically and where to put this code (for example at functions.php file) and where to call it. I know i could change this from wp dashboard but instead i would like to do it programmatically and if a user wants to display wp post as the home page to be able to do it from wp dashboard.

1 Answer 1


You can do it by targeting get_option('show_on_front');

some code which could help would be:

function themename_after_setup_theme() {
 $site_type = get_option('show_on_front');
 if($site_type == 'posts') {
  update_option( 'show_on_front', 'page' );
  update_option( 'page_for_posts', 'page-name' );
add_action( 'after_setup_theme', 'themename_after_setup_theme' );

This will run on theme activation only, remember to change the page-name to the page you want to be set as the homepage.

This isn't tested but have used this on a similar project before


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.