Pages are one of WordPress's built-in Post Types. You'll probably want most of your website Pages to look about the same. Sometimes, though, you may need a specific Page, or a group of Pages, to display or behave differently. This is easily accomplished with Page Templates.

learn more… | top users | synonyms

23
votes
2answers
15k views

Create custom page templates with plugins?

Is it possible to make custom page templates available from a plugin?
9
votes
6answers
6k views

How to *remove* a parent theme page template from a child theme?

I'm using the TwentyTen theme to create a child theme, but I can't seem to get rid of the 'One column, no sidebar' page template that is in the TwentyTen parent theme. I thought just copying it over ...
9
votes
5answers
2k views

How can I add an option to the Page Template list from a Plugin?

I've been looking around for the past couple hours for a way to create a custom page template from within a plugin but haven't had any luck yet. What I am specifically trying to do is add an option ...
8
votes
4answers
2k views

Is there a WordPress plugin that registers a plugin file as a custom page template?

I need to create a plugin that makes custom page templates available in wp-admin. I'm wondering if someone has tackled this already, as it seems like a pretty typical process?
7
votes
2answers
5k views

Getting only direct child pages in WordPress with get_pages

I am trying to fetch all direct children of a page. But I am getting all children and grand children as well. Any ideas? PHP Source: $args = array( 'child_of' => $post->ID, ...
6
votes
2answers
2k views

How to Change 404 page title

i have try many methods after searching on internet but unable to ramove Nothing Found from my 404 page title how to do it please help me even i have us this in my 404 page header if( is_404() ) ...
5
votes
2answers
656 views

Creating Ajax backend for Specialised Page Template? Should admin-ajax.php be used?

We're scoping an upcoming project that will require the development of a large php web application within an existing wordpress site - this is for our use only and we've no intention of trying to ...
5
votes
1answer
5k views

How to get taxonomy term of the current page and populate queries in the template

I've been stumbling around trying to figure out how to get a specific taxonomy term of the current page so that I can subsequently populate queries on the page for other post types that share the same ...
5
votes
1answer
1k views

How to get IDs for objects in menu branch?

Is it possible to print content of all menu items, when displaying menu (or branch of menu as in question about displaying menu branches) ? Once I click on About Us I wish for new page to display ...
5
votes
3answers
4k views

Is it possible to stop selected plugins from loading on certain template pages?

I have a template page that has form on that is only used once in my site. The form uses form validation using jquery validate plugin (such a great plugin). Once the cart66 Plugin is loaded, the form ...
4
votes
3answers
739 views

Password protected posts redirects

I have a page associated with a custom template that list all password protected posts. Let's name it MyPage. What I'm trying to achieve is when a user views MyPage to show only once the ...
4
votes
2answers
3k views

Variable use in get_template_part

As far as I understand (from the get_template_part codex) get_template_part is just a wrapper round the PHP require function. So if I have a variable that I have create in a page template file e.g. ...
4
votes
2answers
412 views

Do I need to use The Loop on pages?

I'm writing my first WordPress theme and have a question about the use of The Loop in page templates. The page templates I've looked at all follow basically the same pattern (example from Twenty ...
4
votes
3answers
621 views

Post formats “audio” and “video” only showing in index.php

I have files in my theme called single-audio.php and single video.php, but when I click on an audio post-format or video post-format wordpress uses the index.php instead of my single-audio.php or ...
4
votes
4answers
4k views

When is get_template_part() preferable to simply using the template.php files?

In this post on wordpress.stackexchange.com I asked whether using get_template_part(), as demonstrated in the TwentyTen theme, is a recommended best practice. The general consensus I got was that it ...
4
votes
3answers
1k views

Setting a custom sub-path for blog without using pages?

Warning: fairly pedantic request ahead. I have a design that makes use of posts (I.e., the blog) and a custom post type called "howto". The site front page ("/") has a template that displays the ...
4
votes
1answer
675 views

I put my blog on a subpage, how do I get page title?

I've got my blog setup on a subpage (not the front page) and I'm using the template file home.php, how can I get the contents from the page editor onto this subpage? If I change the title of the page ...
4
votes
1answer
120 views

How to create a template for a custom URI associated with the user

I am working on a site where I am using a plugin called Favorite Posts so logged-in users can add a post (a custom post type) to their favorites. I created a page called my-favorites which allows the ...
4
votes
1answer
586 views

Creating a Custom Post Type for Inserting Preset Content into Post & Pages?

In response to Mike Schinkel's comment (see below) on my post about how to pre-populate content (essentially using a content template)... @Scott B I mean why did you support a file on disk ...
4
votes
1answer
1k views

Set page template for all pages?

I know the page template is set in the wpdb as meta_key = _wp_page_template and meta_value = template.php. How can I write a SQL script to set each post where post_type = 'page' to a specific ...
4
votes
1answer
122 views

Using a page template without a page

Does anyone know if it's possible to use a page template on a URL, even if a page doesn't exist for that page? When building sites, I create the relevant pages to ensure use of the templates, but ...
4
votes
1answer
302 views

How to consolidate multiple static page templates into one dynamic one?

I have a group of themes that a client needs consolidated into one. Everything is fairly straight forward, except each theme has theme-specific page templates. Instead of pooling all the template ...
3
votes
4answers
2k views

How can I create an alternative home page?

I'm working on a site which has a fully customized front page. Now I'm asked to add a more classic looking blog type page which will be reacheable at http://domain/blog. I tried creating a custom ...
3
votes
2answers
3k views

Multiple areas of dynamic content in a page

I am new in Wordpress and what I really can't find how to do is the following: I have a new Page created from the CMS. This pages have different modules with text. Take for example this template ...
3
votes
2answers
791 views

Create built-in pages without creating actual pages

For example: site.com/contact (or site.com/?page=contact if not using permalinks) when someone goes to that page I want to load a theme template, like page-contact.php But I don't want to create a ...
3
votes
1answer
1k views

Dynamically link to the latest post or simulate request of specific post in page template

I want to have a link in the wordpress menu pointing to the latest post of a specific category. Because I am not able put a dynamic URL in the wordpress menu, my approach was to put a page with a ...
3
votes
2answers
770 views

Set page template automatically based on parent

As the title implies, I'm trying to set each new page under X parent to a specific page template. Either through a function/plugin/code eg: if I make a 'swiss cheese' page, that is a children of the ...
3
votes
1answer
5k views

Add custom template page programmatically

I'm trying to add template page from a plugin,and my template page is in this plugin folder.Is this posible?Here is my code: global $user_ID; $new_post = array( 'post_title' => 'Test ...
3
votes
2answers
50 views

How do I Make a custom post type get a custom post template in a plugin

I am writing a plugin in which I am adding a custom post type(called 'events') using register_post_type. Additionally I want it to use single-event.php instead of the regular single.php. The current ...
3
votes
1answer
6k views

how to add a .php file to wordpress

I have a php file in my server (say www.example.com/up/up.php). If i access that file through the url, my site says no page found. but i want to call that php file using url parameter. I want to call ...
3
votes
2answers
1k views

Need to give custom page template for each language in WPML

I need to give each page a custom/different page template for every language page in WPML. eg: Let i have a test page in English and french. Is there any way out so that in English i give sidebar ...
3
votes
3answers
1k views

WordPress keeps fetching the archive page instead of the template page

I have a template set up and I've created a page in WordPress and have chosen the corresponding template in the drop down. I have created templates for several pages of this site and they've all ...
3
votes
2answers
561 views

Dynamically assign same page template to child page as parent

How to assign parent page template to its child pages dynamically?
3
votes
1answer
317 views

Create “File-less” Page Template in Functions.php

(By "Page Template," I mean a theme file with the "Template Name" header that can be selected in the "Template" dropdown field on the page admin.) In multiple instances, I've built page templates ...
3
votes
2answers
583 views

Full width layout for custom post type pages

I'm trying to remove a widget area called 'Primary' from a certain page on a site. This is the function where I manage the sidebars: //ADD CATEGORIES IN SIDEBAR OF SINGLE POST TYPE add_action( ...
2
votes
2answers
162 views

How do I read the value of a custom field of the page?

When creating custom page templates, how do I get the value of a custom field of the displayed page?
2
votes
3answers
1k views

What are the differences between custom post type and custom page templates?

What is the difference between custom taxonomies and page templates and custom post types? I think I understand that taxonomy is used to organize data. CPTs are used to give your data a different ...
2
votes
3answers
162 views

What is a good way to present templated content in WordPress?

I'd like to be able to add a template for a page that will present pages with similar data in the same style. For example, I want to be able to create a "Person Profile" template so that all personal ...
2
votes
2answers
566 views

Can I create a page template, use it once, then hide/remove the option to use it again?

I am working on a WP theme/project that includes several custom page templates that will only be used once each. For example, there is a page with a map and search form for finding things on the map. ...
2
votes
3answers
312 views

Are page/post IDs unique across a whole network?

If I have a page with ID 123, I know my template file page-123.php will be called to render it, but if my theme is used across a network, could a page in a different site also have ID 123? I assume, ...
2
votes
2answers
533 views

How do I modify this page template to show subpage excerpts (not post excerpts)?

I have made a page template which shows linked subpages using this bit of code: <?php $mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'menu_order', 'sort_or ...
2
votes
3answers
307 views

Is it possible to enqueue a raw CSS string directly from within a template file?

I was wondering if it's possible to enqueue raw CSS as a string directly from within a template file? I'm writing a custom template for a page and need to add some style rules for it. What I want to ...
2
votes
2answers
280 views

Custom template for each page

I am creating multiple pages in Wordpress. I understand I can style these with page.php. Is there any way I can style specific pages with custom templates? So for example if I had page About Us I ...
2
votes
1answer
1k views

How to quickly switch custom post type singular template?

I have a custom post type called movies and I need to quickly switch the template that displays the movies cpt on the front end via a link. How can this be done? Files I have: single-movies.php ...
2
votes
3answers
3k views

Simplest way to add a second html editor to the post/page admin?

What's the simplest way to add a second html editor to the post/page admin and show the content in a template? What I need is something like a custom field that supports html, but I don't need the ...
2
votes
1answer
722 views

Advice needed for importing custom field data and database structure

Looking for advice for the best method to accomplish the following. I have a custom page template with several custom fields/taxonomy. The data needed for these custom fields actually resides in ...
2
votes
1answer
236 views

Use is_category(), is_tag(), … in functions.php

I want to check in functions.php if actual page is a category page, tag page, ... but the functions to check it (is_category(), is_tag(), ...) doesn't seem to work, as this condition: ...
2
votes
3answers
442 views

What are the differences between “Latest Posts” and “Static Page”?

WordPress has an option to pick "Latest Posts" and "Static Page" under "Settings" in Admin Panel. My questions: What page template is getting loaded in each of those modes? Why paged stops working ...
2
votes
2answers
484 views

How to make certain page templates visible to admin only

Making a site for a client, I have some pages that the client won't be able to edit or delete. These pages rely on specific page templates. However, I don't want these templates to be available for ...
2
votes
2answers
513 views

How to move style from template file to <head> section?

Imagine the following situation: //header.php contains: <header id="header">logo and navigation</header> //my-template.php contains: <?php get_header(); ?> <style ...