Skip to main content

Questions tagged [page-template]

Pages are one of WordPress' 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.

Filter by
Sorted by
Tagged with
84 votes
4 answers
121k views

Create custom page templates with plugins?

Is it possible to make custom page templates available from a plugin?
jnthnclrk's user avatar
  • 1,825
31 votes
7 answers
94k views

Custom templates not showing up in template dropdown

I've got some problems with templates in Wordpress (multisite). I've created a file in the root of my child-theme folder (template-test.php) <?php /** * Template Name: Test template * */ ?> &...
Tom's user avatar
  • 315
26 votes
2 answers
31k 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, '...
lejahmie's user avatar
  • 373
23 votes
4 answers
34k views

Use a template file for a specific url without creating a page

I wonder if its possible to use a template file for a specific url without having to create a page for that template. This is my simplified problem: I have created a page in WP with some link ...
Keat's user avatar
  • 447
20 votes
3 answers
72k 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 ...
Christopher's user avatar
19 votes
6 answers
21k 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 ...
Osu's user avatar
  • 1,442
17 votes
2 answers
49k views

What does is_page_template() compare against?

Looking through the Wordpress documentation, it says that is_page_template() compares against a "template name", if one is provided. I have a template stored in page-homepage.php called Homepage: /* ...
Django Reinhardt's user avatar
15 votes
3 answers
13k views

What is singular.php?

From 4.3 we have a new template, singular.php. I tried to understand what is it, but I didn't get it. :) The page.php for pages. The single.php for every post types. If we have single-[post-type].php ...
user1452062's user avatar
15 votes
3 answers
92k views

Creating custom blog page template the right way

I want to create a new custom page template for the presentation of blog posts. I realise that when you assign a page to display posts via Settings > Reading, it then will assign home.php to display ...
Ryan Coolwebs's user avatar
14 votes
2 answers
180k views

How to display page content in a page template?

In my WordPress site, I made a custom page template, which contained a custom query [using WP_Query()]. With that query, I can perfectly get the posts of a certain category. But I want to show the ...
Mayeenul Islam's user avatar
14 votes
2 answers
3k views

How to move page template files like page-{slug}.php to a sub-directory?

I want to move page template files like page-{slug}.php to a sub-directory within my theme, in a way that WordPress will recognize them automatically. If the page templates of the said form doesn't ...
manifestor's user avatar
13 votes
8 answers
23k views

How can I load a page template from a plugin?

I want to add page templates to a theme directly from the plugin. The idea is that the template would show up in the dropdown under Page Attributes, and all the code would need to be in the plugin. ...
smartcat's user avatar
  • 313
11 votes
7 answers
17k views

Conditional tag to check if 'page.php' is being used?

I'm trying to check whether the page.php template is being used or not. I've tried is_page_template( 'page.php' ) but it doesn't work. I also can't use is_page() because I only want to do something ...
user1981248's user avatar
  • 1,047
10 votes
3 answers
21k 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() ) ...
realcoder's user avatar
  • 165
10 votes
6 answers
36k views

Page editor missing Templates drop down

Update: As with so many mysteries, the cause turned out to be extremely stupid. I had the file saved in a different theme's directory. Thanks to @a4jp.com I'm building a theme using underscores. I've ...
Thomas Martin's user avatar
10 votes
4 answers
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?
jnthnclrk's user avatar
  • 1,825
10 votes
2 answers
23k views

A check for if is parent page, if has children, if has grandchildren

I have one default page template that I wish to use for two scenarios. I'd prefer to use only one page template for the sake of simplicity for my client. Here's what I'm trying to accomplish: if ...
laura.f's user avatar
  • 191
10 votes
6 answers
5k 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 ...
Jared's user avatar
  • 3,835
9 votes
1 answer
16k views

Define page template in wp_insert_post

How can I set which page template this page, created using wp_insert_post, uses? I want it to use template-blog.php This is my current function; add_action( 'admin_init', 'mytheme_admin_init' ); ...
Poisontonomes's user avatar
9 votes
1 answer
12k views

How to retrieve $_GET variables from rewritten URLs?

I need to receive some special $_GET parameters for a custom page I'm making, i know how to receive this through a simple $_GET like mysite.net/products/?id=1 , but I wanted to use the URL style of my ...
Jonathan DS's user avatar
9 votes
2 answers
3k views

How To Create A Paginated List Of All Categories On My Site?

I want to display an archive page with pagination that lists all the categories on my site, and each link goes to that particular category archive page. So this would be like an archive page of ...
gelleproductions's user avatar
8 votes
2 answers
3k 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 ...
Jamie Ide's user avatar
  • 183
8 votes
3 answers
60k 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 ...
Felix's user avatar
  • 333
8 votes
3 answers
11k 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 ...
lomokev's user avatar
  • 173
8 votes
2 answers
12k views

Passing parameters to a custom page template using clean urls

I am now passing parameters to a custom template in the following format www.example.com/?pageid=12&rid=24&title=this-is-the-title I have created two tables . So I need to fetch data and ...
user7282's user avatar
  • 201
7 votes
2 answers
10k views

is_page_template not working

Hi trying this code below to get working, but no look so far. Idea is simple if page template is page-47.php display <h1>Something</h1> else <h1>This will show on any other page</...
soliddigital's user avatar
7 votes
3 answers
24k 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 ...
user1147's user avatar
  • 802
7 votes
3 answers
8k 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 ...
Steve Fischer's user avatar
7 votes
3 answers
4k views

Page Template as Custom Post Type Archive

My goal is to have the slug www.domain.com/resources used by a Page Template rather than an Archive Page, and have single CPT posts as children of that slug, such as www.domain.com/resources/post. ...
wackerfuss's user avatar
7 votes
3 answers
8k 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 ...
aendra's user avatar
  • 1,045
7 votes
3 answers
3k views

Define custom Page Template without its own .php file

Is there any way of defining a Page Template from some function/filter/hook, without having any .php file containing the comment at the top of the page to declare the Template Name? For example, ...
MikO's user avatar
  • 595
7 votes
3 answers
7k 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 ...
AlxVallejo's user avatar
  • 1,461
7 votes
4 answers
21k views

How to edit contents of dynamic_sidebar()?

I know PHP well but I'm new to Wordpress. I got an incomplete Wordpress website. It has a static home page with an Aweber newsletter form. I tried digging into installed theme and in home.php I came ...
Zeeshan's user avatar
  • 171
6 votes
4 answers
24k views

Is there a default template file for child pages / subpages?

This seems like a very simple question. I'm looking for something like sub-page.php or page-child.php where I can do some different things on the child pages of my theme. They are different enough ...
timshutes's user avatar
  • 1,010
6 votes
5 answers
9k views

Wordpress page edit does not save selected template

The feature did work in the past however pages now seem to default to 'Default Template'. I can see my available page templates in the drop-down on the Page edit page, however after saving the admin ...
Ingmar Boddington's user avatar
6 votes
4 answers
7k 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 ...
Tom Auger's user avatar
  • 7,076
6 votes
3 answers
13k views

How to move page templates to custom folder?

I created page templates that use the page slug, for example, page-contact.php, page-gallery.php etc. or page id, for example, page-2.php, page-11.php etc. How can I move these templates to a ...
Den's user avatar
  • 81
6 votes
2 answers
10k views

Ways to have multiple front-page.php templates that can be swapped out?

I essentially want to create several different front-page.php templates with different loops and layouts and then present an option in the admin panel to select one template on one day and a different ...
Edmund Heaphy's user avatar
6 votes
1 answer
2k 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 ...
daniel.tosaba's user avatar
6 votes
3 answers
1k 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 ...
mrwweb's user avatar
  • 10.3k
5 votes
2 answers
18k views

How to remove all styles for certain page template?

I know how to create child themes and page templates. I have a child theme of Salient called Salient-Child, and I have a page template called blankPage.php. For all pages that use this template, I ...
Ryan's user avatar
  • 225
5 votes
1 answer
7k views

Loading custom page template via plugin

I am following a rather outdated tutorial on custom post types and the last step is to create a custom page template, where this is intended to show all posts of the custom type in archive listing ...
Aidan Knight's user avatar
5 votes
2 answers
2k 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 ...
HeavenCore's user avatar
5 votes
4 answers
2k 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 ...
Bucky's user avatar
  • 235
5 votes
4 answers
13k views

Overriding page template using page_template filter

I tried add_filter( 'page_template', 'single_page_template' ); function single_page_template( $template ) { if ( is_singular( 'dwqa-question' ) ) { $template = ...
Prafulla Kumar Sahu's user avatar
5 votes
2 answers
28k views

Display all posts from specific categories on a page

I want to display all posts from specific categories on a single page. Therefore I edited the page.php file in my theme folder. I added an 'if-clause' to check which page currently being displayed and ...
mybecks's user avatar
  • 351
5 votes
1 answer
181 views

Is it possible to manipulate the list of page templates?

After answering this question I wondered if it is possible to manipulate the dropdown list of possible page templates that's available when you edit a page. WordPress derives this list from the ...
cjbj's user avatar
  • 14.8k
5 votes
2 answers
1k views

Having different sidebar content for MANY pages?

I am continuing on from a topic I already posted but with a different angle. Please bare with me as I try to provide as much information as possible. I am looking to add a simple text area called "...
Nimara's user avatar
  • 161
5 votes
2 answers
4k 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 ...
alme1304's user avatar
  • 173
5 votes
4 answers
1k views

Add Content to Page without shortcodes

The site I'm working on has a couple of pages that needs to be filled with different content elements like text image combinations, sliders, lists of content, etc. The client would need to re-order ...
sven's user avatar
  • 151

1
2 3 4 5
25