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' );
?>
Dear Friend, I´m try to get my posts in my blog page and I saw your code but where can I put this?
Index.php or and different file?
Regards
Frank
This code is intended for plugin authors. You should use the usual settings page, settings->reading.
do you know what hook you would need to connect with to create this static home page? Or does the update_options do this automatically?
Good question. IIRC plugin activations hook fire before init, so I'm not sure if that would be safe.
For themes, no idea, afaik they don't have activation hooks.
I use this code on wpmu_new_blog, but that's probably not what you're looking for :-)
I am assuming this goes into functions.php, but where could it be placed to just fire once, on first install of a theme?
I thought that a splash page would be better and have noticed your code. However I am not a coder. Can you help?
Thanks
Thanks in advance.
So Q: How can I create static page in this new version?
TIA
I am a beginner in word press, I want to create a Joomla Site In word press.
Also I've not any source code or admin id/password for that site. So Guide me how to create
theme & other functionality. thanx.
HELP!
How can I get event to also be displayed on this theme's "Avenue Theme" carousel on th homepage. For all other posts I tag the post to be "featured" and upload a larger image so it adds it to the homepage carousel. Is this possible with events manager? Any help would be appreciated
Also will this work with multsites?
www.grektown.com.au
Thanking you in advance