Dave Liu
Dave Liu

Reputation: 1132

How do I edit an individual page in WordPress

I don't want to edit the template files - I'd like to make a new template file. I'm looking in the MySQL registry, but all I see is a table for posts, not pages. Someone mentioned the editor earlier, but that doesn't help with creating new templates.

I think I create a php file in my content>theme>my_theme directory, but I'm not certain. Thanks for any help.

Upvotes: 1

Views: 3327

Answers (2)

FloatingRock
FloatingRock

Reputation: 7065

This should help you out:

enter image description here

It shows you which pages map to which template, and how new templates should be created. As an example, if you created an About Us page (singular, static page with the default page template), here's what Wordpress checks for:

  1. Is there a file called page-about-us.php?
  2. No? Is there a page called page-#.php (where # is the pageid)
  3. No? Just render the generic page.php

In your case, if you want to edit a single page (it's a page right, not post?) .. then simply creating a file called page-$slug.php would be sufficient .. WP will use that "template" when rendering that page.

If it's still a bit unclear, check out the source link here (it makes things crystal clear!): http://make.wordpress.org/docs/theme-developer-handbook/part-one-theme-basics/template-hierarchy/

Upvotes: 1

Radley Sustaire
Radley Sustaire

Reputation: 3399

You can create your own template files in your theme directory, or a subfolder. Use a comment on top that has the name of the template.

/*
Template Name: Custom Template
*/

You can assign the template to a page under the "Page Attributes" box in the dashboard.

Of course you need more than just that comment to display anything in your template. You might stay by copying the content of your theme's index.php, then edit from there.

Upvotes: 0

Related Questions