Change WordPress address

55 Views Asked by At

Question... How can i change a file address like wordpress addresses such as http://localhost/author/me that was http://localhost/wp-content/my-theme/author.php ?!! I want to create new file that doesn't included wordpress files and don't like that show it's address like second address example above... Rather i want create new address such http://localhost/new

1

There are 1 best solutions below

0
On

You can Create a New file or template file as under the steps,

Step 1: Locate your theme's existing pages

  • Locate your theme's directory on the local server or production server.
  • Drill down to the theme folder to see your existing page templates. Locate page.php.
  • Open it with a script editor.

Step 2: Insert name code

 /*
 Template Name: My-New-Page-Template
 */

  • Paste or type this code right before get_header(); ?>

  • Replace My-Page-Template with your own template name. You don't need the dashes you an use spaces. Also, note that in the above example there's no opening PHP tag because it's up higher in the file. If your opening PHP tag is on the same line as the get_header(); ?> , then your code needs to go right after the opening tag (with a space between).

Step 3: Save your new file

  • Save the file with a new name and a .php extension. For example - NewPageTemplate.php. Put the file on the server at /wp-content/themes/yourtheme/NewPageTemplate.php (it's better not to have spaces in a file name.)

Step 5: Add a custom Content in the Main div tag of content

  • Open the file.

  • Add Custom Content of code to the page.

<div id="content" role="main">
  /* Add Custom Content */
</div>

Step 6: Apply your template to your pages

  • Go to Pages > Add new.
  • Choose My-New-Page-Template from the Page Attributes.

Get More Details, you can follow the link - https://codex.wordpress.org/Templates

And Also follow the example of create a new file or template file - https://www.ostraining.com/blog/wordpress/custom-page-template-wordpress/