Sunday, July 8, 2012

ho to Set static front page and blog page programmatically in WordPress

You want to make sure the About and Blog pages exist, so create them before if necessary, see wp_insert_post()
<?php

// Use a static front page
$about = get_page_by_title( 'About' );
update_option( 'page_on_front', $about->ID );
update_option( 'show_on_front', 'page' );

// Set the blog page
$blog   = get_page_by_title( 'Blog' );
update_option( 'page_for_posts', $blog->ID );

// Switch to our theme
//switch_theme( 'Template', 'stylesheet' );
?>

1 comment:

  1. I am so fascinated with the entire content of your site, from the material to the theme. I really had a great time reading and watching this post.



    aion accounts

    ReplyDelete