How can I create a page with a specific URL?

I would like to have a few pages which can be reached by anyone who knows the URL, but which are not listed on the WordPress menu. I would like those pages to have a name rather than a number, but I don’t see a way to do any of these things.

That is, I can create a page named “Special” and not include it in the menu, but I cannot go to

mysite.net/Special

only to

mysite.net/?page_id=561

I also want to keep the /?page_id=561 navigation, because this is an established site with a lot of links set up to use that style of URL. I just want a few specific pages to have nice names that will resolve.

Does WordPress have such a feature? Should I try to get IIS to direct /Special to /?page_id=561 ?

Hmm. In choosing tags for this question, I found “url-rewriting” and http://codex.wordpress.org/Rewrite_API/add_rewrite_rule – it looks like I could add

function custom_rewrite_basic() {
  add_rewrite_rule('mysite.net/Special', 'mysite.net/Special');
}
add_action('init', 'custom_rewrite_basic');

To “functions.php” – the one I see is in my theme (twentytwelve) folder… so would I just insert this in there?

Solutions Collecting From Web of "How can I create a page with a specific URL?"

If you tried to create a static file and then load it like a normal file, you may have had trouble because a WP page as we call it, is actually not actually 1 file, but rather a lot of files that tell WordPress how to put together information queried from the database based on the query that is used in the URL. Most modern WP installs use pretty-links which don’t have users see that query “?page_id=561” because it make urls easier to read and more semantic. (Before doing what I list below, I’m pretty sure that if you switch to permalinks, your old query links should still work because permalinks change pretty-links down into queries behind the scenes.)

If you are absolutely positive that you don’t want to make the switch to pretty-links, then you could load WordPress on your own through a static file. To do this we first need to require the wp-blog-header.php file that is located in the WP root directory. So to test this out you can save a file into the root directory, name it secret-page.php and put in the following lines. After you should be able to access it at mysite.com/secret-page.php ( provided mysite.com is your wordpress install directory. It could possible be a different directory then the root folder of your website. Look for the folder with wp-config.php inside it.

<?php
require( 'wp-blog-header.php' );
define('WP_USE_THEMES', true);

get_header();
wp_head();
?>
    <div id="main">

Normally I would not put a file in the root directory, but you also don’t want to put that file in your theme folder and have the url be http://www.mysite.com/wp-content/themes/secret_page.php ( unless you want to make a rewrite rule redirecting the url yoursite.com/secret-page.php to yoursite.com/wp-content/themes//secret-page.php ). If you do that, just change the require line above to require(‘../../../wp-blog-header’); if you use a typical theme folder. For every folder above the root folder you place the file, you will have to put a set of “../” before the file name, which just means “go back one folder”

To explain what the file above did, it ran the wp-blog-header.php file which started WordPress for you, then the second line told WordPress we wanted to use themes. This way we can get the same look as your site regardless if this file is in the theme folder or not, we will have access to your regularly used theme because WP has it saved as an option in the Database.

Next, the get_header(); line went to your theme and began to print out your websites page, and after that, wp_head() runs all the WordPress head actions. If you are a developer, you can continue on from here alone. If not, but you can handle your own, then goto your theme folder and copy code from index.php or page.php ( whichever page you most want to imitate ). Check out this codex page, http://codex.wordpress.org/Template_Tags – it will explain how template tags work, that will help you to add the same functionality your sites pages usually have to this new page, which is unlisted and only available to people who know the URL. You don’t have to use the ” – that is actually just to demonstrate that is where you should begin your html. I hope this helped.

All you need is to enable permalinks.

I strongly recommend switching to permalinks: /%postname%/

The old links will still work. (In fact, every single permalink type is just an alias for the default one: ?p=%post_id% ).

Being able to give people easier to remember links to pages is a secondary reason. The main one should be boosting page rankings in search engines.

Google places pages that have the searched keyword in the URL higher. It’s a fact.

As for not showing page in menus, just disable the “Add new pages to this menu” checkbox in Dashboard > Appearance > Menus. And add/remove any pages/posts to/from the menu while at it.