How set a custom URL for a new theme file in WP?

You cannot directly create index111.php go to mysite.com/index111. Because the WordPress loading principal is like the following explanation. You could do similar things with custom templates but not exactly the index111.php. Also, it is assumed that you use permalinks too.

WordPress loading method

Because WordPress is running a query based system. That’s means, basically it read links like mysite.com/?p=1234 and find if there is any post with 1234. If you turned on permalinks with Post name (settings -> permalinks) with Post name selected and saved.
Then it allows mysite.com/something where something is a page you have created in Pages menu on the left. It then try to match if there is a page something and find its id, if page exists, it loads, redirect to 404 if not. WordPress regard something as slug. When you create a page, a post, slug will be automatically generated based on the title you insert. Characteristic of a slug

  • Editable
  • Unique, if slug found in the database, WordPress will add number to your new slug. You could have pages with same title but their slug could not.

It is editable.

*** So what method to use depends on what did you try to accomplish.

To accomplish what you would like, there are many ways, here illustrate 2 simple methods which you could refer. If you understand the above concept well, there are still other ways to do so by using custom codes and more advanced methods.


by Template for Page Selection

Step to add

  1. create a template page and save as filename template-{$name}.php
  2. add a page and select this template from Template list on the right sidebar in the Edit Page menu
<?php
/**
 * The example template for index111, the following "index111" will be displayed from the selection menu
 *
 * Template Name: index111
 *
 * @package myPackage
 */

get_header(); ?>

    <!-- content here -->

<?php
get_footer();

pros

  • could select page template from the edit page menu when adding a new page
  • don’t need to pre-create all pages
  • could apply to many different pages with same template

by page-{$slug}.php template

You create page with same slug with the template file.
Steps

  1. You add a page in Pages menu, name it with index111 with slug index111,
  2. create page-index111.php in your theme. Then when you go to mysite.com/index111, it will load page-index111.php.

pros

  • could have custom template for each template

cons

  • need to create each page to use respective template with same slug name
  • if you need 100 templates, then you need to create 100 pages
  • because it use slug to create, template name must be unique, if you would like to use same set of elements, you might need to add a separate files and the require it.

error code: 523