The get-template-part tag has no wiki summary.
0
votes
1answer
17 views
get_template_part in admin
I am trying to use get_template_part when creating a page in the admin section of my site. However, it does not seem to be working. Does this function not work in the admin section? What alternative ...
0
votes
0answers
24 views
when implementing a “GET_Template_part”, something weird happens
OKay, i read the wordpress codex about
get_template_part.
i get it work, BUT, when it load the .php, it actually prints out the text/word:
get_template_part()
right before the rest of the ...
0
votes
2answers
30 views
Remove portion of header code from home page only
I have this code in the template file header.php:
<div class="dynamic-header">
<?php if(function_exists('show_media_header')){ show_media_header(); } ?>
</div>
I want to ...
0
votes
0answers
48 views
Posts 2 Posts, losing connection in template parts
I am using the Post 2 Posts plugin to connect different post types. My code works perfectly when it's all in one file (archive.php). The problem I have is taht I want to split out the part that does ...
1
vote
0answers
38 views
get_template_part from plugin
This is default get_template_part function inside WordPress:
function get_template_part( $slug, $name = null ) {
do_action( "get_template_part_{$slug}", $slug, $name );
$templates = array();
...
0
votes
0answers
12 views
Get template part with Except [duplicate]
I am using
<?php
wp_reset_query();
query_posts('posts_per_page=20&post_type=post&post_status=publish');
get_template_part('index');
?>
in single post bottom. Its ...
0
votes
1answer
77 views
Conditional get template part
My index page look like this...
<div id="ad-id">google ad code goes here </div><br />
<div id="post-id">My posts are goes here</div>
I use
...
6
votes
3answers
199 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 ...
1
vote
2answers
90 views
Using get_template_part to retrieve a template file based on current post type
I'm trying to use get_template_part to retrieve a template file based on the current post type (slug) the user is in. The template file just includes an image that is used specific to specific post ...
0
votes
1answer
72 views
Checking whether template part is loaded in a page
I have a template part like this:
<nav id="subpagemenu" class="sidebar">
<?php get_template_part( 'nav', 'subset' ); ?>
<?php get_sidebar(); ?>
</nav>
Both of these ...
3
votes
1answer
67 views
Is it safe/recommended to use wp_enqueue_script function outside the functions.php file?
I created multiple post formats, and when i use an audio post format, i want to include some additional javascript for the audio player.
So, i include the content-audio.php like this:
<?php ...
0
votes
1answer
125 views
Use a separate template for the home page only
I use Pinboard theme (it has a very complicated structure, but it is nice).
Image how it works
Select a template in this way it changes for all posts, pages, etc. and do not give you more choice.
I ...
0
votes
1answer
74 views
Organize template parts and page templates in folders in regards of template hierarchy
Hello and happy new year
Suppose one has a large theme composed of several post types, page templates and a bunch of custom loops and template parts which is best keeping in separate php files. ...
0
votes
4answers
140 views
How do I display an image before the first post of the loop when I'm using get_template_part?
I have used $count before, but never run into this problem. I cannot get it to work. I have limited php background, so please be patient with me! Here is the $count setup code:
<?php $count = ...
1
vote
1answer
296 views
How to localize inline script called with ajax
I have a loop of posts and I allow a user to edit each post using ajax. When the edit button is clicked for the post I use ajax to retrieve the template part containing the edit form for the post. ...
1
vote
2answers
518 views
Using a custom WP_Query with get_template_part loop
I have a query for a custom post type:
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$books = new WP_Query(array(
'post_type' => 'wiki',
'posts_per_page' => ...
-1
votes
2answers
220 views
First post outside of loop, homepage only?
Because of the way my templates are structured, I need to pull the first/sticky post from the site outside of the standard loop, just on the homepage. I'm using _s (underscores.me) as a base, so the ...
1
vote
1answer
438 views
passing argument to get_template_part() or a better way to code
I have this include … event-list.php
<?php
/**
* The loop that displays upcoming events
*/
?>
<ul class="event-items">
<?php
$yesterday = time() - 24*60*60;
$args = array(
...
5
votes
4answers
250 views
Is there a variable for a template parts name?
One you have called a template with get_template_part() (or locate_template()) is there a way to know what template you are in.
For example if you call get_template_part('loop','archive'); from ...
2
votes
2answers
178 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 ...
0
votes
1answer
171 views
How do I get standard posts to open up in their own template when using get_template_part()?
It seems to me that twentyelven opens standard single posts using the file content-single.php yet when I try the same code and files they open for me in content.php
here's the code I have in ...
0
votes
0answers
193 views
Why is my Starkers Theme Search.php template breaking [closed]
I am using the Starkers Theme as a foundation to build my WordPress theme and I have noticed the search.php page completely breaks the design of my site. Does anyone have similar experience with this ...
0
votes
2answers
433 views
how to replace get_template_part('loop','tag') with explicit styled version?
So my theme has a tag.php, that contains this line:
get_template_part('loop','tag');
that runs the loop and spits out the tag entries. I'm modifying it to include post thumbnails (using ...
0
votes
2answers
582 views
get_template_part() - post-meta not working?
Maybe I simply do not understand what get_template_part() is doing …
I have a file called event-list.php that should work as template for other pages and files so all my events (a custom post type) ...
4
votes
1answer
403 views
Should we use get_template_part() in functions files instead of include_once?
I'm using the theme-check plugin to check my theme for errors and recommendations, I'm using get_template_part() in theme files like header.php and index.php but in functions.php I'm using ...
3
votes
1answer
2k 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. ...
0
votes
1answer
543 views
Post Format single-loop.php using get_template_part
I have set up to use post formats gallery and video in addition to the standard. I am editing the loop-single.php to give it different layouts for each post format, but I'm to include ...
1
vote
1answer
97 views
Unexpected results with conditionals inside template part
Scenario: I have a template part loop-product.php which i am calling from home.php, taxonomy.php and a page template template-products.php. Inside that template part loop-product.php file i am setting ...
0
votes
1answer
57 views
Custom fields in post later used in loop
How i can add custom fields to custom post templates, and later print them in The Loop?
Better explanation: I want to have a custom field in "Add New" window, which will be added as some meta data to ...
0
votes
1answer
87 views
Taxonomy template for all taxonomies attached to certain post type
For instance, I have a product post type and I would like all the taxonomies associated w/ this type, such as size, color, material etc to display using the same template without having to 1. create a ...
0
votes
1answer
642 views
how to modify request to get_template_part()?
i am modifying a P2 theme for a specific purpose, and it uses the get_template_part( 'entry' ) function to get the the whole entry html.
What i then get is the who <li> element, but i want to ...
0
votes
1answer
117 views
what template-part to call, to have my post in the center of the page?
i was wondering if you could help me : i would like to change the center of my page only with my posts : (all my posts will be in the same category) : how can i construct the page :
so : 1.my menu ...
0
votes
2answers
310 views
wordpress header leaks into body in a specific template
very strange problem, that happens only in one specific template. part of the part "leaks" into the tag - and I can't figure out why.
the "header.php" code:
<!DOCTYPE html>
<html ...
0
votes
2answers
290 views
Exclude function from homepage only?
There is a function in a theme that I am using that does some pagination stuff. I do NOT want that function to show up on my home page (only), so I'm trying to set up an if/else statement but can't ...
-1
votes
2answers
1k views
How to make get_template_part always check child theme first?
How can I force WP to always check the child theme folder first when running get_template_part?
Example: child theme loads get_template_part('content', 'inventory') in single.php. Because all child ...
4
votes
4answers
3k 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 ...
0
votes
2answers
364 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, ...
2
votes
1answer
420 views
Possible to use pagename inside get_template_part?
I'd like to grab the current page name and pull that specific template part per page. This way I can just set up a generic tier-1 template that calls in a secondary section based on the current page's ...
0
votes
1answer
128 views
strange parse error when including a loop template within another template
I have a loop template called loop-event-details.php where I have code to display each event.
My main page template is called events-page.php. I use the following code to include the loop template:
...
7
votes
4answers
11k views
How to use get_template_part()?
Could someone please explain to me how this function works? I know what it does but when I look at the source code in the twenty_ten template, I don't get how all loops are being collected in one ...
0
votes
1answer
1k views
Custom post type index (maybe using get_template_part)
I just created a custom post type "publication" with the slug "publications".
Now im stuck trying to view all the publications index in a URL like:
http://www.myExampleSite.com/publications
Do I ...
1
vote
2answers
1k views
get_template_part and template file names
I have a custom post type that is going to use a loop in a couple different places and I wanted to make maintaining those loops easier. I remembered that get_template_part() is available and figured ...
1
vote
2answers
468 views
get_template_part inside get_template_part?
Ever tried this?
// template file
do_action( 'my_hook' );
// ex. functions.php
function my_hooked_template_part() {
get_template_part( 'my_loop_part_file', 'default' );
}
add_action( 'my_hook', ...
15
votes
3answers
6k views
Passing Variables through locate_template
While I've typically used include or require on their own to save long term code maintenance I've started to use get_template_part and locate_template as using built in WordPress stuff is always best.
...
10
votes
3answers
1k views
get_template_part vs action hooks in themes
It seems to me both of these afford the opportunity for the end user to modify a theme without actually editing the themes files (via child themes).
My question is, is one method preferred over the ...