Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am new to WordPress, and I need to make some quick changes.

How can I find the Page that is referenced by a permalink: e.g. for www.example.com/mypermalink how can I locate the actual WP Page so I can find it either in the file system or in the WP Pages list?

share|improve this question
    
I'd still like to know this, but I have found the page using "Search" in the WP Admin Pages list. I was able to find that this page has no content, but is based on a template, and I am off to discover where the HTML content is specified... –  jmsmcfrlnd Dec 29 '10 at 14:15
add comment

1 Answer 1

up vote 5 down vote accepted

Addressing both your original question and the question implied by your comment ...

Finding the page ID

Every post and page within WordPress is given an ID. By default, WordPress uses the ID in the link structure: http://www.example.com/?page=ID or http://www.example.com/?p=ID (for posts). You can change this to a more user-friendly structure called "pretty permalinks" that will use the page slug in the URL instead: http://www.example.com/my-page-slug.

In practice, though, these permalinks can become very long. This is bad for certain situations (i.e. posting to Twitter), so WordPress retains the shorter ID-based URLs as "shortlinks."

You can figure out the shortlink for a particular post or page by navigating to that page, right-clicking, and selecting "view source." Then look through the source for a specific section of meta tags:

<meta name="generator" content="WordPress 3.0.3" /> 
<link rel='shortlink' href='http://example.com/?p=2' /> 

This "shortlink" tag tells you that you're looking for post #2.

Finding the page in WordPress admin

You've already discovered the easiest way to find a post or page - just search for the page slug when you're in the admin. This will find it almost every time, or at least give you a small list of possibilities.

Another way is to use the ID you discovered above to jump straight to the post/page edit screen. Every post or page edit screen uses the following URL structure: http://example.com/wp-admin/post.php?post=ID&action=edit

Just substitute the ID you discovered above for ID in the URL and you'll be taken to the post/page edit screen for that content.

Template Files

Page templates are defined by your theme. They'll all be located somewhere in the /wp-content/themes/YOUR-THEME/ folder. The name of the page template (which you saw on the post edit screen) might give you a hint as to which file you're looking for, but I can't guarantee it.

Just know that all page template files will begin with the following code:

<?php 
/* Template Name: PAGE TEMPLATE NAME */ 
?>

So if you have more than one template file defined by your theme, looking for this tag will help you identify the specific one you'll need to edit. This template will define the HTML and PHP code used by pages that specifically call out that particular template.

share|improve this answer
    
Well done - thorough and useful post. –  jmsmcfrlnd Jan 11 '11 at 22:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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