Lesson: How to make a static page your “home” page
-
Alright, I figured I’d make this a lesson post since I’ve seen a few people wanting to do this. This are the steps that need to be taken if you want to have a wordpress “page” your home page before people can see your blog.
1. First step is to create a plugin with Ryan’s plugin:
<?php
/*
Plugin Name: Page to Front
Version: 1.0
Plugin URI: https://www.ads-software.com/
Description: Choose a page from the DB to display as the front page of your weblog.
Author: Ryan Boren
Author URI:
*/// Put the id of the page you want to display here. To find the page id,
// go to Manage->Pages in the admin UI and look at the ID column.
$ptf_front_page = 1;function ptf_front_page($query_string) {
global $ptf_front_page;$query = new WP_Query();
$query->parse_query($query_string);if ($query->is_home) {
$query_string = add_query_arg(‘page_id’, $ptf_front_page, $query_string);
}return $query_string;
}add_filter(‘query_string’, ‘ptf_front_page’);
?>
‘`You can name it something like pagetofront.php or whatever you want really.
2 . Next, create the page that you want people to see when they first come visit your site. You could make it as simple as just having text with your theme look, or you could create a whole new template for your home page and then just create it as a page.
If you’re making a new template, don’t forget to add the following to the top of your php file:
<?php
/*
Template Name: Home
*/
?>3. Note the number that the page is given when you create the page, and edit the plugin with the page that you want as your new “home page.”
4. Next up, you’ll need to edit your permalink structure so that you’ll be able to get from your home page to the rest of your blog. Without setting up the permalink structure, I believe that you’ll have no way of getting back to your blog since the plugin will keep redirecting you back to the home page.
You’ll want your permalink structure to look something like this:
WordPress Address: https://mydomain.com/blog
Blog Address: https://mydomain.com/
Permalink Structure: /blog/%year%/%monthnum%/%day%/%postname%/That should be all that you need to do. You’ll now be able to have a static home page which is part of wordpress.
All of this is assuming that you have wordpress installed in your root directory instead of a folder. You could do this if you had wp installed in a folder, but then your home page would be located at mydomain.com/wp with your blog then at mydomain.com/wp/blog.
Hope this helps!
- The topic ‘Lesson: How to make a static page your “home” page’ is closed to new replies.