: How does WordPress determine which template to show? So I recently set up a Wordpress blog and I've noticed that when I make posts, the link is http://www.domain.com/?p=2. I was wondering how
So I recently set up a Wordpress blog and I've noticed that when I make posts, the link is www.domain.com/?p=2. I was wondering how you could specify which file to use to parse such requests.
For example, domain.com/?author=1 now returns a page with all posts made by that author, but how and where does it get configured to go here? I checked to see if it was .htaccess related but it appears not to be.
More posts by @Kimberly868
2 Comments
Sorted by latest first Latest Oldest Best
WordPress has a complex template hierarchy that determines which template files are shown based on each page request.
Template files are called from the active theme's directory at /wp-content/themes/theme-name. For example, if you request a single post, the single.php file in the active theme's directory will be displayed. If you request an author, the author.php template will be displayed.
If WordPress can't find those templates, it looks for the next related template available, eventually falling back on index.php if it can't find specific templates, as detailed in the hierarchy and shown in this diagram (click for large version):
If you are trying to customise the author or post templates, it is best to do that by editing the author.php and single.php templates in your theme directory, rather than attempting to restructure the hierarchy (defined in wp-includes/theme.php) yourself.
If you are trying to create 'pretty urls', you can do that using the Permalinks panel under the Settings header in the WordPress admin area.
everything going to / will cause apache to load up index.php
so if you delete or rename index.php in the root, nothing will work
The question mark denotes the start of a query string, this will be passed to that file (index.php)
And from there wordpress will do its magic
.htaccess will turn those 'ugly' urls into pretty ones such as /page/2 or /authors/1
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.