Title: Page Keys
Author: Thorsten Frommen
Published: <strong>March 6, 2015</strong>
Last modified: January 7, 2026

---

Search plugins

![](https://ps.w.org/page-keys/assets/icon-256x256.png?rev=1106640)

# Page Keys

 By [Thorsten Frommen](https://profiles.wordpress.org/tfrommen/)

[Download](https://downloads.wordpress.org/plugin/page-keys.1.3.4.zip)

 * [Details](https://test.wordpress.org/plugins/page-keys/#description)
 * [Reviews](https://test.wordpress.org/plugins/page-keys/#reviews)
 *  [Installation](https://test.wordpress.org/plugins/page-keys/#installation)
 * [Development](https://test.wordpress.org/plugins/page-keys/#developers)

 [Support](https://wordpress.org/support/plugin/page-keys/)

## Description

**Register page keys, assign WordPress pages to them, and access each of these pages
by its individual key.**

Have you ever wanted to access a specific page from inside a template file? Of course,
you could query it by its title. But what if someone wanted to rename the page? 
Okay, so we choose the slug. But maybe that someone also thought editing the slug
as well to make it fit the new title was a very good idea. Yes, I know, it is not.
But that someone either didn’t know, or didn’t care. Okay, so let’s use the page
ID. Oh, wait, now that someone, _by mistake_, permanently deleted that page. After
having visited the frontend that someone created a new page, with the exact same
title and the exact same slug as the original page. But that damn page still won’t
show.

This is exactly when _Page Keys_ kicks in.

#### Usage

What this plugin is all about is providing a means to accessing specific pages by
unique and therefore individual keys. And doing this is quite simple. On the _Page
Keys_ admin page, you can add as many unique page keys as you like. For each of 
these page keys, you then select a (published) page. Hit the _Save Changes_ button,
and you’re done already.

Suppose you now want to access a specific page in one of your theme’s template file.
After having defined a page key and having assigned a page to it, you can get the
according `WP_Post` object by calling `get_page_by_key( $key )`. In the rare case
where you already have a function of that name defined within the global namespace,
you would have to set up such a function by yourself. In principle, this is just
a copy of what you can find in the `functions.php` file **of this plugin**.

**Filters**

In order to customize certain aspects of the plugin, it provides you with several
filters. For each of these, a short description as well as a code example on how
to alter the default behavior is given below. Just put the according code snippet
in your theme’s `functions.php` file or your _customization_ plugin, or to some 
other appropriate place.

**`edit_page_keys_capability`**

Editing the page keys is restricted to a certain capability, which is by default`
edit_published_pages`. The reason for this choice lies with the fact that user, 
who is capable of editing a published page (e.g., changing its status to `draft`),
implicitly is able to compromise any page key mapped to the page.

    ```
    /**
     * Filter the capability required to edit the page keys.
     *
     * @param string $capability Capability required to edit the page keys.
     */
    add_filter( 'edit_page_keys_capability', function() {

        return 'manage_options';
    } );
    ```

**`list_page_keys_capability`**

Accessing the plugin’s settings page is restricted, too. In order to distinguish
between users who are only allowed to see the existing page keys as well as their
respective page, and users, who are able to edit page keys, there are two individual
capabilities. The default for accessing the settings page is `edit_pages`.

    ```
    /**
     * Filter the capability required to list the page keys.
     *
     * @param string $capability Capability required to list the page keys.
     */
    add_filter( 'list_page_keys_capability', function() {

        return 'read';
    } );
    ```

**`page_keys_show_admin_notice`**

Depending on how exactly you are working with the plugin, the admin notice informing
you about page keys that don’t have a page assigned might be more annoying than 
helping. Gladly, there is a filter to turn this off.

    ```
    add_filter( 'page_keys_show_admin_notice', '__return_false' );
    ```

#### Contribution

To **contribute** to this plugin, please see its [**GitHub repository**](https://github.com/tfrommen/page-keys).

If you have a feature request, or if you have developed the feature already, please
feel free to use the Issues and/or Pull Requests section.

Of course, you can also provide me with translations if you would like to use the
plugin in another not yet included language.

## Screenshots

 * [[
 * **Settings page** – Here you can manage your page keys (i.e., add, edit, delete).

## Installation

This plugin requires PHP 5.3.

 1. Upload the `page-keys` folder to the `/wp-content/plugins/` directory on your web
    server.
 2. Activate the plugin through the _Plugins_ menu in WordPress.
 3. Find the new _Page Keys_ menu item in the _Pages_ menu in your WordPress backend.

## Reviews

There are no reviews for this plugin.

## Contributors & Developers

“Page Keys” is open source software. The following people have contributed to this
plugin.

Contributors

 *   [ Thorsten Frommen ](https://profiles.wordpress.org/tfrommen/)

“Page Keys” has been translated into 1 locale. Thank you to [the translators](https://translate.wordpress.org/projects/wp-plugins/page-keys/contributors)
for their contributions.

[Translate “Page Keys” into your language.](https://translate.wordpress.org/projects/wp-plugins/page-keys)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/page-keys/), check 
out the [SVN repository](https://plugins.svn.wordpress.org/page-keys/), or subscribe
to the [development log](https://plugins.trac.wordpress.org/log/page-keys/) by [RSS](https://plugins.trac.wordpress.org/log/page-keys/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### 1.3.4

 * Fix security issue.
 * Compatible up to WordPress 6.9.

#### 1.3.3

 * Fix warning message due to loading text domain too early.
 * Compatible up to WordPress 6.8.1.

#### 1.3.2

 * Fix `get_page_by_key()` incorrectly returning current post.
 * Compatible up to WordPress 6.2.2.

#### 1.3.1

 * Escape translated strings.
 * Improve namespace imports.
 * Compatible up to WordPress 4.2.4.

#### 1.3.0

 * Fix PHPDoc blocks.
 * Improve namespace imports.
 * Compatible up to WordPress 4.2.3.

#### 1.2.0

 * Complete refactor.
 * Grunt integration.
 * Compatible up to WordPress 4.2.2.

#### 1.1.0

 * wordpress.org release.
 * Compatible up to WordPress 4.1.1.

#### 1.0.0

 * Initial release.

## Meta

 *  Version **1.3.4**
 *  Last updated **3 months ago**
 *  Active installations **80+**
 *  WordPress version ** 3.5.0 or higher **
 *  Tested up to **6.9.4**
 *  Languages
 * [English (US)](https://wordpress.org/plugins/page-keys/) and [German](https://de.wordpress.org/plugins/page-keys/).
 *  [Translate into your language](https://translate.wordpress.org/projects/wp-plugins/page-keys)
 * Tags
 * [keys](https://test.wordpress.org/plugins/tags/keys/)[page](https://test.wordpress.org/plugins/tags/page/)
   [pages](https://test.wordpress.org/plugins/tags/pages/)
 *  [Advanced View](https://test.wordpress.org/plugins/page-keys/advanced/)

## Ratings

No reviews have been submitted yet.

[Add my review](https://wordpress.org/support/plugin/page-keys/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/page-keys/reviews/)

## Contributors

 *   [ Thorsten Frommen ](https://profiles.wordpress.org/tfrommen/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/page-keys/)