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 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.


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):wordpress template hierarchy

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.