Navigation and Page Links
Posted 04th Oktober, 2018
Wordpress posts and pages are stored in the database. When a visitor loads a specific page, the relevant content is requested from the database.
Permalinks and Navigation Explained
Wordpress supports ugly and pretty links, which it terms permalinks.
- Ugly (default) links use the ID of each post or page. A page link might be http://yoursite.com/?p=5. This is neither aesthetically pleasant, or particularly SEO friendly.
- Pretty links are human readable, for instance http://yoursite/post-name.
Pretty links can be enabled as follows:
- Ensure
mod_rewrite
is enabled on the server. This should be as simple as having the default Wordpress .htaccess file added. - Log in to the Wordpress Admin area
- Navigate to
Settings
, thenPermalinks
. - Update the link settings and save.
Navigation Broken
The navigation should be generated automatically from the link settings and pages created. Errors can be caused by the following:
Dead Links
Links may be have been hardcoded into a theme or post. If this is in the main navigation, it can be fixed as follows:
- Log into the Wordpress admin area
- Navigate to
Appearance
>Menu
>Edit
- Correct or remove the old URL
Styling Broken or Menu Blank
If the Styling on the menu is not displayed correctly, this could be a result of a couple of things.
- Ensure navigation is enabled in the Wordpress admin area under
Appearance
>Top Menu
andAppearance
>Header Menu
. - An issue with header.php in the theme file. The simplest solution is to roll back the theme to a backup using Fixed.net. Alternatively the theme could be reinstalled or changed.
- A plugin may have been used to create the menu. This plugin can be disabled to revert to the Wordpress default navigation, or a reinstall could be attempted.
All pages return a 404 not found
If the only workable page on a site is the home page, and all other pages return a 404 not found, then it is likely the .htaccess file is broken.
A .htaccess file sets rules that a server should follow when serving files. The Wordpress .htaccess rules tell Wordpress that - no matter what URL is requested - the default index.php file should be loaded instead. This enables Wordpress to then query the database based on the actual URL requested and return the desired content.
The default Wordpress .htaccess content is as follows:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>