Your cart is currently empty!
Create Set Static Front Page and Blog with Content on Theme Activate
Categories: WordPress How to Tutorials
Recently Adding a function to my theme that user don’t have any problem while setting front page on their theme, So here is solution that create front page automatically and set it to static front page also you can put some content on it as you desire.
If users desire they can change page from Dashboard > Settings > Reading > here front and blog page can be changed
Set Static Front Page and Blog with Content
if (isset($_GET['activated']) && is_admin()){ $new_page_title = 'InsertCart Front'; $new_page_content = 'My Short Code [Any short code function] Titles This is the page content'; $new_page_template = ''; //ex. template-custom.php. Leave blank if you don't want a custom page template. //don't change the code bellow, unless you know what you're doing $page_check = get_page_by_title($new_page_title); $new_page = array( 'post_type' => 'page', 'post_title' => $new_page_title, 'post_content' => $new_page_content, 'post_status' => 'publish', 'post_author' => 1, ); if(!isset($page_check->ID)){ $new_page_id = wp_insert_post($new_page); if(!empty($new_page_template)){ update_post_meta($new_page_id, '_wp_page_template', $new_page_template); } } $setpage = get_page_by_title( 'InsertCart Front' ); update_option( 'page_on_front', $setpage->ID ); update_option( 'show_on_front', 'page' ); // Set the blog page $setblog = get_page_by_title( 'Blog' ); update_option( 'page_for_posts', $setblog->ID ); }
Just copy and paste above code into theme function.php file Above code won’t overwrite your current page if already created. Rewrite above settings as you want let me know if any question or suggestion about my post.
Comments
One response to “Create Set Static Front Page and Blog with Content on Theme Activate”
Exactly what I was looking for, thank you!!!
Grabber Pro
Original price was: $59.$39Current price is: $39.Insertcart Custom WooCommerce Checkbox Ultimate
Original price was: $39.$19Current price is: $19.Android App for Your Website
Original price was: $49.$35Current price is: $35.Abnomize Pro
Original price was: $30.$24Current price is: $24.Medical Portfolio Pro
Original price was: $31.$24Current price is: $24.
Latest Posts
- How to Handle Sudden Traffic Spike in Website – Do Node Balancer Really Help
- How to Use AWS SES Email from Localhost or Website: Complete Configuration in PHP
- How to Upload Images and PDFs in Android Apps Using Retrofit
- [Fix] File Permission Issue in Apache Website WordPress Not Writable to 775
- Best PHP ini Settings for WordPress & WooCommerce: Official Recommendations
Leave a Reply