You need to learn how the WordPress template hierarchy works.
It is very important for any individual who wants to learn WordPress or take their current WordPress experience to the next level to know of and understand all of the different aspects of the WordPress Template Hierarchy.
If you plan on consolidating, or organizing the content on your WordPress website, it is essential to understand how your WordPress website handles the requests made from each of the visitors who arrive on and navigate through your WordPress website.
Here’s a list of links which you should read from top to bottom:
- Theme Development
- Template Hierarchy
- Child Themes
- Conditional Tags
- Stepping into
Templates - The Loop in Action
Now for my .02 in regards to your particular situation…
Create your static paces in the WordPress Backend Administation area (domain.com/wp-admin/
). Give them a title, modify the “slug” if desired to change the URL of the page, and insert some content.
Read through the links posted earlier in my answer. Then come back to here.
Make a file page.php
and put it in ./wp-content/themes/<your-theme/
directory. This will be your default template for all “static pages” on your website.
Now, if you wanted different functionality or layout for a specific page, you have a couple of options.
Option #1) Create individual files for each different page. You can do this by making a file called page-<your-page-slug>.php
or page-<your-page-ID>.php
.
Option #2) Use conditional tags for each different page, within your page.php
file.
Example:
if(is_page('about')){// Page with slug of "about".
// do stuff
} elseif(is_page(28)){// Page with ID of "28".
// do stuff
} elseif(is_front_page()){// Home page of your website.
// do stuff
} else{// Any other page.
// do stuff
}
Now, if you’re going to be more or less hard coding your links in your layout… Consider using site_url();
.
Example: <a href="https://wordpress.stackexchange.com/questions/160817/<?php echo site_url("/about/'); ?>">About</a>
You could do it using the actual page information.
$page = get_post(28);
if($page){
echo '<a href="'.get_permalink($page->ID).'">'.$page->post_title.'</a>'.PHP_EOL;
}
Now if you really wanted to get fancy… You could use global variables. Globalling the current post object (a/k/a current page).
if(is_page('about')){// Page with slug of "about".
global $post;
echo '<h1><a href="'.get_permalink($post->ID).'">'.$post->post_title.'</a></h1>'.PHP_EOL;
}
It should also be noted that when setting up your “blog section” of your site that you should check out the reading settings in the WordPress backend administation section. WP Admin -> Settings -> Reading
Set your front page and a page for posts. The page for posts is where your blog will be located. index.php
is the default template file for your blog posts. You can setup different templates for each area of your blog. home.php
would be your default template file for the “main blog page”, category.php
would be all your blog posts which have an assigned category to the post. tag.php
would be all your blog posts which have an assigned tag to the post. etc…
I cannot go too in-depth on this topic, as for there is just simply way too much information to cover in one answer. This is all explained in the above links earlier in my answer. I can assure you, that if you read and understand those links, you will be well on your way to a solution.