Within the context of WordPress Theme-ing, the term 'template' refers to PHP files used to display content.

learn more… | top users | synonyms (1)

35
votes
3answers
2k views

Opinions and recommendations on the best barebones base theme [closed]

Preamble I'm finding myself building more and more WP sites "from scratch" as it were (ie: ignoring any theme designs out there and just creating a design wireframe purely on the needs of the client. ...
26
votes
9answers
29k views

get name of the current template file

I've found this to display the current name of the file used in template: function get_template_name () { foreach ( debug_backtrace() as $called_file ) { foreach ( $called_file as $index ...
23
votes
2answers
15k views

Create custom page templates with plugins?

Is it possible to make custom page templates available from a plugin?
19
votes
1answer
37k views

How to change the default registration email ? (plugin and/or non-plugin)

After a new user registration, WP sends out an email with the login / password, and a link to the login page. Is there a way to change this defaut email template? I'd also like to change the subject ...
14
votes
8answers
17k views

How do you find out which template page is serving the current page?

When you activate a wordpress theme, it's always a hassle to find out which file to go to change things. Any idea how to simplify things? But on the other hand, considering the get_template_part ...
13
votes
5answers
5k views

single-{$post_type}-{slug}.php for custom post types

My favorite part of the Wordpress template hierarchy is the ability to quickly create template files for pages by slug, without having to edit the page in Wordpress to select a template. We can ...
12
votes
3answers
8k views

What's the difference between home.php and index.php?

If I create a home.php file, it seems that WP will use that instead of index.php, so index.php is never used? What are the differences between these two template files (located in the theme folder)? ...
11
votes
3answers
12k views

How do I get the size of an attachment file?

I'm using the following template code to display attachment links: $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => ...
11
votes
2answers
7k views

Get custom post_type's archive URL

It seems like stupid question. But, I can't figure it out :(. I need to display button at home that goes to custom post_type's archive URL (archive-{post_type}.php). How do I do that?
11
votes
1answer
15k views

How to create custom URL routes?

I have a very peculiar requirement, hopefully I can explain it without being too confusing. I created a page template where I list some properties I get from an external XML file, so far no problems, ...
9
votes
2answers
14k views

Adding Page Attributes Metabox and Page Templates to the Posts Edit Page?

(Moderators note: Title was originally "How can I add the "Page Attributes" and/or "Page Attributes > Template" selector to POSTS editor") WP currently only allows the assignment of a "template" to ...
8
votes
3answers
1k views

Is there any way to use get_template_part() with folders?

I'm wondering if there is any way to use get_template_part() with folders? My main folder has a lot of files now because I put every re-usable element in a separate file. I'd like to put them in ...
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?
8
votes
2answers
876 views

What's the purpose of the paged.php file?

In context of the template hierarchy chart? From what i gather, the paged.php file is something to do with an archive?
7
votes
2answers
2k views

Looking for WordPress System Diagrams

I am looking for WordPress chart/diagram system design. I found only the template hierarchy diagram, but it's only part of the system. source: ...
7
votes
5answers
3k views

How to rearrange fields in comment_form()

Im using a custom filter to change the fields, but can´t figure out how to change the order of the fields in the comment form. Desired order: comment field (first/top) name email website This is ...
7
votes
3answers
1k views

Can't get a custom template taxonomy page to display

I've been trying to wade my way through learning the ins and outs of taxonomies and how to integrate them into themes and I've run into a pretty basic issue that I can't seem to figure out. I started ...
7
votes
1answer
5k views

How does printf( __( ) ); work?

Today I work through a theme to get a better understanding of WordPress and templating. I discovered this: <?php printf( __('Designed by %s', 'Anyword'), '<a ...
6
votes
3answers
6k views

Any advantage to using get_header() over include('header.php')?

The basic theme - in fact every theme I've looked at - uses get_header() to include the header file, but I don't see any reason for doing so. What's are the advantages of using get_header() instead ...
6
votes
1answer
182 views

How to redirect to post if search results only returns one post

I want to send visitors to my search.php after a search to display list of posts. If there is only one search result, user can directlyto the post in question(something like GOOGLE's I am Feeling ...
6
votes
3answers
310 views

Is it possible to override the result of get_template_part()?

I'm working on a child theme, I strongly prefer not to override the main template files in order to maintain simplicity of the child theme as well as minimize the amount of code and maintenance over ...
6
votes
1answer
3k views

Taxonomy, Terms, and Template Files

I have post type 'product' and hierarchical taxonomy 'types' attached to it. In this taxonomy, I have terms: 'dry-clean', 'washer', etc. With several sub terms on each terms. In my situation, I need ...
5
votes
5answers
377 views

Updating WordPress overwriting customization tweaks - strategies?

Twice now I've updated wordpress, only to realise that (facepalm) it overwrites some changes I've made to the custom template - to sidebar or something similar. Obviously I don't HAVE to update, ...
5
votes
2answers
3k views

How to customize the default HTML for Wordpress Attachments

I'm using Wordpress 3.0.1 (most recent as of now) and working around the Whiteboard theme. It seems that for attachments (images, specifically), Wordpress generates the HTML automatically and it ...
5
votes
3answers
1k views

Print WordPress template filename(s) for debugging

I've taken over the maintainance of a large WP-MS powered site. The site has ~200 templates, many page specific, and with no standard naming procedure. It would save a lot of time if while surfing ...
5
votes
4answers
6k views

Dynamic template serving, change theme_root using add_filter from current theme

Some plugins use the 'template', 'option_template' and 'option_stylesheet' to dynamically serve (alternative) wordpress templates. For example, Nathan Rice's ServeDefaultToIESix. For Example - ...
5
votes
4answers
568 views

How to control output of custom post type without modifying theme?

I have a custom post type 'properties' that I'd like to control the HTML output for. For simplicity, let's focus on the archive view. As a basic example, here is what a loop looks like in an ...
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
5answers
707 views

How to show a under construction page for a domain but still be able to work on index.php?

I installed a WordPress for a domain name. When I use this domain name will point to index.php in my template. I want show a under construction page for this domain name, but the other hand I still ...
4
votes
5answers
3k views

Different widgets on different page templates?

If I have a couple of different Page templates, how would I show a different collection of sidebar widgets for each of these templates? I'm using the Starkers theme as a starting point.
4
votes
2answers
2k views

Use [embed] filter in template files

WordPress autmatically embeds a youtube video's if I use: [embed] http://www.youtube.com/watch?v=Xog1T5dUxcw [/embed ] This is great, but it doesn't work if I use it in an template file. I have a ...
4
votes
3answers
3k views

Creating a default Custom Post Template that a Theme can override

I'm in the midst of building a Wordpress Plugin that adds a custom post type, for which I'd like to include a default template to display. Essentially, this is an event management plugin, and the ...
4
votes
4answers
4k views

Consuming an external API in WordPress?

I have a client who has a WordPress website, and he want to extend it to add new functionalities. These functionalities are included in a website I have already done (a kind of search engine over a ...
4
votes
1answer
1k views

Is there a way to parse shortcodes in PHP?

Many plugins don't provide a documented way to access their functions from within PHP (e.g. when building a custom theme), but only shortcodes to insert in posts. Is there a standard way of executing ...
4
votes
2answers
12k views

Can I assign a template to a custom post type?

can I assign a template file to custom post types? I have created a custom post type called items, and I would like to assign templates to the items like you can do with pages.
4
votes
2answers
739 views

What are the current recommended best-practices for comments.php?

I'm getting ready to submit a theme to the .Org repo and wanted to make sure that everything is in ordnung. One of the biggest holes left in my design is the comments template. I've taken a look at ...
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
855 views

Post/Page Preview Template

Is there a way to have a custom template php file that is only used for previews instead of it using the single.php file? This way the user knows they are in preview mode?
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
3answers
972 views

Custom Post Types 404 Issue

I dont know why my custom post types render the Page not found. This is the code I am using to register custom posts. www.example.com/products/product1/ renders 404 where as ...
4
votes
3answers
2k views

Get page IDs based on which template they are using?

I have a situation where I need to provide a dropdown of pages in a widget, based on whether they are using a specific template. In other words, for all pages using template 'Foo', get the post ID. ...
4
votes
3answers
11k views

What is the link to my default “archive” page?

I'm using twentyten and have overloaded home.php to do some custom stuff. However, I would still like to have a page that lists all of my recent posts, archive-style. I can get to an archive page for ...
4
votes
2answers
530 views

Child Theme: how to override variables?

I'm going to build my first Child Theme. I understood how to override functions (hope!), but how to override variables? For example, in a Premium Template I want to change the values of feed variables ...
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
410 views

Show only 2nd level of navigation depending on active navigation

For example, suppose a menu like so: Parent 1 Child A Child B Parent 1 Child C Child D Child E Parent 2 Child F In a certain part of my template, I want something to show depending on ...
4
votes
1answer
2k views

wp_get_attachment_image returns different image size

It is a bug? wp_get_attachment_image( $attachment_id, 'post-thumb-size-small'); Same code, called in template, and in AJAX call returns same image SRC, but different image width and height. dumb ...
4
votes
1answer
78 views

add/apend templates 'transparently' via plugin to currently active theme or child theme?

Cross posting my trac question here in the slim hopes that someone here has run into the same issue and has already come up with some proof of concept code I can try: In building a custom 'theme ...
3
votes
4answers
4k views

How to check if a shortcode exists?

I'm using do_shortcode function to add shortcode in my template. But i would like to check if that shortcode exists before display them. I mean like this If (shortcode_gallery_exists) { echo ...
3
votes
1answer
2k views

Template issues getting ajax search results

I'm trying to put search results into a div with ajax. The issue is I'm getting errors saying undefined function have_posts() when the the search template is accessed. It also took issue with ...