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

learn more… | top users | synonyms (1)

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.
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 ...
3
votes
1answer
202 views

Templates for Custom Post Types and Custom Taxonomies

I am working on a custom theme for a network of sites that are deployed under a WordPress MultiSite installation. Within these theme I create 4 custom post types that have two taxonomies added to all ...
3
votes
6answers
3k views

How to force TinyMCE in WordPress to replace newlines with <br> tags and not with <p>&nbsp;</p>

TinyMCE editor inserts <p>&nbsp;</p> instead of <br> tags when I press enter in my text for a new line. How to force TinyMCE in WP to replace newlines with <br> and not ...
2
votes
3answers
4k views

Hide page visual editor if certain template is selected?

How do I hide the page editor (WYSIWYG editor) if the current page is set to a certain template. I have the following code already to add in custom meta boxes when certain templates are chosen: ...
1
vote
1answer
3k views

tag.php doesn't work with tags on a custom post type post?

here's another stumper. I have a tag.php page. It works fine, unless you click a tag that is in a post associated with a custom post type. Then it doesn't work. Its like that tag, doesn't exist. But ...
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?
3
votes
2answers
776 views

How to prevent execution of default query, while preserving ability to use WP_Query in template?

PROBLEM: I'am trying to prevent execution of default WordPress query for custom category template. I have found a possible solution, but looks like it preventing execution of all post queries: ...
2
votes
2answers
3k views

When calling wp_title(), do you have to create some kind of “title.php” file?

... or does wp_title() already handle the various contexts in your blog? This could clarify for me how I can achieve a reusable index.php file without having all the conditional statements inside it ...
1
vote
1answer
733 views

Passing variables to templates (alternatives to globalizing variables)

I want to make my WP code simpler (there's some mess within header.php, page.php etc.). So, for example, I want to set something like this global: $foo = get_option('foo'); So $foo will work ...
1
vote
1answer
521 views

On Taxonomy Template page, want to add Post_Type

I have a custom taxonomy template page in my theme. Essentially, when someone clicks on a term link into this taxonomy, I -ALWAYS- want to add a specific post-type to the query. I'm not entirely ...
1
vote
3answers
1k views

Best approach for loading a sidebar Only if the screen max-width is >900px?

I have been playing around with media queries quite a bit lately and I love the concept. It is so easy to display images or change div floats depending upon what the users screen max-width is. I'm ...
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 ...
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 ...
2
votes
1answer
601 views

How to set a fall back template for a custom post type in a plugin?

My custom plugin creates a custom post type, and I want to theme my own "single-my_custom_cpt.php" file. However, I want to store it in my plugin folder, and allow that it be over-written in the ...
2
votes
2answers
314 views

Load different template file when condition met?

If I visit a page on my WordPress site, WP goes and determines what template file it should use based on the template hierarchy. If I'm doing some logic checking in the hook init and say my ...
1
vote
3answers
2k views

Global variable set in the template's header.php is unable to echo in footer.php

E.g. I set this in header.php in my template: <?php $postidextra = get_the_ID(); ?> <?php $sidebar_state = get_post_meta($postidextra , 'rw_sidebar_state', true); ?> And I can echo ...
1
vote
3answers
2k views

wordpress - load a template based on the URI

I have a number of custom of post types - i.e. 'windows', 'doors', 'garages' and I want to load a custom template (special.php) whenever my wordpress site has a url that looks like this: ...
0
votes
3answers
310 views

Unable to run jQuery script in my template file

I really want to run a simple code in my template file. E.g. if I put somethign like this in my page.php: <script type="text/javascript"> jQuery(document).ready(function($) { ...
0
votes
1answer
2k views

Two exact templates, sidebar showing in one but not the other

I'm using the Roots WP Theme and for some reason when copy pasting the page-custom.php to create a home page template. The new homepage template is showing the sidebar but not the original page-custom ...
0
votes
1answer
407 views

Custom Page Template [closed]

Could somebody help me make a custom page template? I'd like to have a basic page (with sidebars, header and footers) and a table for data. I'd like the data to be taken from custom fields. ...
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
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 ...
3
votes
2answers
1k views

How to get Images included in Post

is possible to get images added to a post programmatically? I am working on custom template (my first) and I need to display Images added to a post in specific way.(first image as title image and the ...
2
votes
1answer
324 views

Sharing templates with the JSON API?

Is there any way to share 'templates' between JS and Wordpress? For instance, this sort of modest seat-of-the-pants templating feels ok: var AJAXSuccessFunc = function(data){ // calling this on ...
2
votes
4answers
2k views

Grid layout “last” class to every third item

Seems like a trivial problem but I can't get it to work. I need to add class="last" to every third post. Here is my code: <?php $count = 0; $my_query = new ...
1
vote
2answers
117 views

Template for specific post of custom post type

I have the CPT "event". I have created single-event.php. I want one particular event to use a different template than single-event. I read elsewhere that this could be done by creating a ...
1
vote
1answer
148 views

Single page template for custom post_type

I registered a custom post type with the following code: #Register custom post type for Stars of the Month add_action( 'init', 'sdp_create_star_type' ); function sdp_create_star_type() { ...
1
vote
1answer
3k views

How to add a new product type on woocommerce product types? [closed]

I want to add a new custom "product type" to woocommerce plugin: Tried to duplicate one of currently exist product type files (woocommerce template structure) as a new file (file name and inside ...
1
vote
1answer
39 views

Can I obtain differents links for different installed theme?

I have to show 3 differents template to a person and then say to him: "Please, choose one of these templates and I will use it for your web site" So the question is: Have I to install 3 differents WP ...
1
vote
1answer
462 views

Mass update excerpt

I'm using a photoblog theme which upon creating a new post it takes the post attachment and saves a modified "img src" string into the excerpt field. It then uses <?php the_excerpt(); ?> to ...
1
vote
1answer
89 views

Template plugin for blog posts? [closed]

can someone recommend a plugin to do the following? My wordpress CMS has two types of users: administrator and editor, both of whom are not technologically savvy, so they need things to be super ...
1
vote
2answers
2k views

display different template based on post type

Hay, i have a custom post type "Events", however this is basically a post type, so it inherits the post.php template page. Is there anyway to use a different template (i.e events.php) if the content ...
0
votes
1answer
48 views

Add pagination to blog

I want to limit 3 blog entry snippets per page and include pagination for additional pages. Here's what I have so far, but pagination isn't working. <div id="page-content"> ...
0
votes
2answers
76 views

Change site template from php

What is the argument to pass to switch theme, when I have the result of wp_get_themes()? $args = array( 'allowed' => true ); $themes = wp_get_themes( ); foreach ($themes as $theme) ...
0
votes
2answers
56 views

Wordpress theme & site not loading after moving files

I was recently created a custom application for wordpress. So while doing so in my file manager (I use the one provided by godaddy(my webhost)), I moved all the files from the [DOCUMENT_ROOT] ... the ...
0
votes
2answers
587 views

index.php template is used instead of blog page

I am trying to set WordPress so that home page is static, and the blog page is a separate page. So, I created two page templates in my theme., lets call them home_template and blog_template. Then, I ...
0
votes
2answers
940 views

Post formats template

I would like to know what template wordpress uses to display post formats archive pages? What is parent template file that is used when there is no specified template file and what is specified ...
0
votes
2answers
39 views

How do you modify Page Template?

Do I just go to Appearance->Editor and then pick the template and modify the PHP code directly, or is there a more "non-coding" way of doing it? I'm using a theme with a contact form, and the whole ...
0
votes
1answer
702 views

comments_template not working correcly in custom template files

In a template file that I am using as page, I want to allow only 2 users to post comments and allow to all other users to only see these comments( not allow them add comments). my template file is: ...
0
votes
2answers
260 views

Prevent private post 404

I want private posts (for those not logged in) to use the single.php template just as public posts do, at the moment they get thrown over to the 404.php template. I've had a good look through the ...
0
votes
1answer
348 views

How to retrieve depth of menu into template

In wp_nav_menu i use for the menu, with custom walker, i can get the $depth parameter in the start_el function function start_el(&$output, $item, $depth, $args) but, outside this ...
0
votes
1answer
617 views

Display different header images based on current page

I want to display, based on the current page another header image. Short example: Home -> Image A PageId 1,2,3,4 -> Image B (2,3,4 are childs of page 1) PageId 5, 6 -> Image C ... I tried to ...
0
votes
1answer
1k views

How to Display an Image Uploaded through a Meta Box in a Template?

I am just learning to create a meta box to upload a file in wp-content/uploads folder through this code: //display image meta box function display_image_box() { global $post; wp_nonce_field( ...
0
votes
2answers
153 views

Using locate-template & shortcodes doesn't appear to work

For organisation, I'm trying to split up the functions.php file into separate files. In particular the functions for shortcodes in a separate file, with the shortcodes being defined in functions.php. ...
0
votes
1answer
1k views

Use template of parent category for single post sub-categories

I have single post templates in a folder in my child theme marked "single". I need the sub categories to use the same template as their parent. I've read a dozen tutorials all of which were more than ...
0
votes
1answer
486 views

Guest author's post not display in author template

I am using this filter to display guest author on post, but i want guest author's posts to appear in the author.php template also. This is my guest author code (inside functions.php). <?php ...
0
votes
1answer
698 views

Stream Video Player does not work with do_shortcode()?

I have downloaded a plugin called Stream Video Player, which has a shortcode. If I put the shortcode into the content editor, it works well and it displays the video. However, if, inside a template I ...
0
votes
2answers
394 views

TwentyTen: Overloading template.php files vs. get_template_part

I'm studying TwentyTen, under the assumption that it contains the best practices for writing themes and modifying them using child themes. I'm noticing what looks like a really redundant practice, ...
0
votes
1answer
764 views

where can I see my custom post type archive template?

I am working with wordpress 3.1 and have custom post type of whitepaper. My single-whitepaper template seems to be working. But the archive template (archive-whitepaper.php) is not. And this after I ...