It is a WordPress core function that loads template parts inside theme templates. It makes it easy for themes to reuse sections of code like pagination, header images, menus, etc.

learn more… | top users | synonyms

0
votes
1answer
12 views

Both the require and add_template_part function are not including the file

I'm trying to add a require function in my functions.php, to include a file that is in the wp-content folder. I first tried this with the function content_url . 'filename.php'So the line of code ...
-1
votes
1answer
70 views

Make a PHP file with a function

I want to use the breadcrumb function as listed here: https://gist.github.com/melissacabral/4032941 Putting the code in functions.php works for me, but I would rather have it in a separate PHP file. ...
5
votes
3answers
136 views

Check if partial file is called from within header.php or footer.php

I am including a partial file both in header.php and in footer.php with get_template_part('content-form'); Is there an if clause I can use to check from where the file is being called? If it is ...
2
votes
2answers
47 views

_wp_page_template to dynamically use template

I'm wondering if it is at all possible to set display a page template chosen by the user within the context of a query_posts using get_template_part. In other words, I have set up a page template to ...
3
votes
2answers
47 views

Finding Page Template and Displaying Content

So, I'm building a theme for a client with one page layout functionality. Currently, I'm allowing the user to create a parent page, and the modules within that page are separate pages that will be set ...
1
vote
1answer
43 views

Is there any way to get all the name or slug of template parts used in a page?

I am developing a custom plugin where I am using a single page template and changing the template parts only using ajax,I want to retrieve the template parts slugs or name (like custom-header.php, ...
1
vote
1answer
37 views

Is there any problem if I use get_template_part like this?

I want to display different content on my home page and in single pages, so I am using the following code in index.php: get_template_part( 'template-parts/content-home', get_post_format() ); At ...
0
votes
1answer
31 views

Displaying a custom post type using get_template_part into a specific layout

I am new to wordpress custom themes and am trying to recreate this website (http://www.divecarib.com/) as practice. I am trying to find the correct way to achieve the following: I have created a ...
1
vote
0answers
26 views

Loading template parts conditionally in Customizer

Here are my issues: I have layout options in customizer for full width or two columns. For fullwidth sidebar will not be loaded. The problem is if the setting is currently on full width when ...
0
votes
1answer
43 views

Does get_template_part() content gets parsed if it's not executed?

My page templates are currently built up as shown in first example but I really don't like that half of the template is just sitting there, not being used and takes the server resources for no good ...
0
votes
0answers
32 views

Does get_template_part() effects the site loading time?

Does the fact that I use the get_template_part() method instead of just entering the code makes my site loading time a bit slower?
0
votes
1answer
25 views

Include template file from plugin to theme

I am using a plugin in my theme options. I copied the entire plugin directory in my child theme directory and correctly included all the files in the theme functions.php. The plugin options files is ...
0
votes
0answers
37 views

Entire site breaks when error in a php file because of multiple get_template_part in functions.php

I bought a WordPress template and I'm modifying it to fulfill my needs, But I have a problem. Whenever I there is an error in one PHP file, the entire site (including the homepage) breaks. I see that ...
1
vote
0answers
126 views

How to use jPList with search results

I've been working on a real estate site and looking for a way to refine search results page + update pagination, instantly, like the big name sites (ie hotpads.com, trulia.com, hotels.com, etc.). ...
1
vote
1answer
74 views

What is the best way to organize template parts?

I am trying to bring some order in to theme files and would like to separate templates parts. I see that underscore ( _s ) has done something similar but they moved only content templates inside , ...
0
votes
1answer
41 views

Use another theme template in my theme

I want to use a different theme's portfolio page in my theme. I just want the content (portfolio layout of the other theme) but my own (active theme) header, footer, sidebar, and everything else. Is ...
0
votes
1answer
64 views

get_template_directory() returns wrong address on VPS

I'm having the following problem with a Wordpress installation on a VPS server. I'm trying to read from a JSON file but the returned address from get_template_directory() is wrong: $url = ...
0
votes
1answer
38 views

Get template part with CPT and Custom Taxonomy conditionals

I have two Custom Post Types Video and Gallery and a Custom Taxonomy Status with the term Featured. Right now I'm showing these CPT in my index.php, but I want to style each of them, so I'm using ...
0
votes
1answer
29 views

When using shortcode, content stops generating after the_content

Yesterday I implemented a shortcode, but now my comments and related posts stop appearing. The source of a rendered page now only displays <div class="posts-group"> &...
0
votes
0answers
34 views

Get template part using a custom taxonomy term

I've been using the following code to get a template part based on the parent term. It was working fine until I updated WordPress to v4.4 earlier today. Since updating if there is also a child term ...
0
votes
1answer
426 views

Combining shortcode and get_template_part

I manage a wordpress site and have created a template part that I usually paste below the content. <div class="posts-group"> <h2>Featured store products</h2> &...
0
votes
0answers
35 views

get_template_part for each level of taxonomy term w\control if empty term

before we start, thank's for your time. Structure: cpt = corsi tax = argomenti tax_term = parent tax_term_child = child tax_term_child_granchild = grandchild Current code (on taxonomy-argomenti.php)...
0
votes
1answer
171 views

get_template_part for each level of taxonomy term

before we start, thank's for your time. Structure: cpt = corsi tax = argomenti tax_term = parent tax_term_child = child tax_term_child_granchild = grandchild Current code (on taxonomy-argomenti.php)...
0
votes
1answer
30 views

Get_template_part seems to be ignoring my template

I am developing a website that requires specific pages to have certain elements change color in addition to a full-width calendar page. I figured that using page templates and changing what ...
0
votes
1answer
79 views

Check for the main query from the template

Besides the main loop in index.php, I'm calling several other custom queries across the theme, like this: $new_query = new WP_Query(array( // some args )); if ($new_query->have_posts()) : ...
0
votes
1answer
713 views

get_template_part() does not work if you call it when you are in a subfolder

Say for example you have a directory like this: theme - subfolder - template.php content-job-listing.php If I try and call get_template_part like so get_template_part('content', 'job-listing'...
0
votes
1answer
84 views

get_template_part doesn't output all data

I hope I get some help with get_template_part function. my starting point is a contact-us template (it's got map+address+emailform) that stores data in the database my other template is where I have ...
0
votes
1answer
617 views

Can't load search results with ajax

I'm trying to load search results on my page without reloading. I tried multiple approaches already, but I still can't make it work, despite using someone else's confirmed solution. Please find the ...
0
votes
1answer
268 views

Get_template_part() problem with the_content()

I am creating one page wordpress theme - i am new to wordpress dev. The one page website have sections which represents pages. So every section on front page is page created via admin panel. There is ...
0
votes
0answers
19 views

Grabbing Custom Single Post Template displays WSOD

I'm trying to use a custom Single Post Template & call it via my single.php (It wasn't drawing from single-press.php otherwise) My main goal is to have the Custom Single Posts not display the ...
0
votes
0answers
261 views

Using require_once for parent-directory not working but is working in sub-directories

I'm building a custom theme and I'm attempting to use require_once __DIR__ . '/templates/variables.php' in my footer.php file, to keep from repeating code that contains variable information... I keep ...
0
votes
1answer
373 views

Echo a shortcode div after every 3 posts

In my wordpress home.php file, I have placed an increment loop with the help of a few stackexchange threads: <?php if (have_posts()) : ?> <?php $count = 0; ?> <?php while (...
0
votes
1answer
258 views

using get_template_part() inside a widget and passing variables

I read that get_template_part() should only used by themes not plugins, I don't know if using it inside a widget function (created by the theme) is considered as a plugin or not. Anyway, I'm trying ...
0
votes
2answers
193 views

Get_Template_Part And Two Global WP_Query On Frontpage

I am working on a site where I use get_template_part to retrieve the loop. In the header of the template I specified so it runs the global query. global $user_ID, $wp_query, $pagename; Now, what ...
0
votes
0answers
198 views

Call to undefined function get_template_part() error on theme

PHP Fatal error: Call to undefined function get_template_part() in /var/www/public/wp-content/themes/digit/index.php on line 1 Hey guys, I am getting this error in my php error logs. I have a ...
0
votes
1answer
271 views

how could I load a different template part by page

I would like to use get_template_part(); to load a different template parts on different pages. so on the home page it loads get_template_part( 'content', 'home' ); and on the blog page it would load ...
0
votes
1answer
40 views

When to use content-pagename.php?

I have seen themes using content-pagename.php in many themes. This file is usally used by get_template_part function. Also, pages are named as page-slug.php or page-id.php. However, I am not clear ...
0
votes
1answer
146 views

Removing get_template_part in child theme

Parent Theme loads some template files in its functions.php as follows: get_template_part ('lib/login/register.php'); I want to remove this file in child theme and include my custom php templates. ...
1
vote
2answers
41 views

Which custom query am I in and how can I access its properties & methods?

Sometimes there's no way around creating a custom query, but when I do and then loop through it, I often want to use get_template_part() within the custom query loop to pull in a template I already ...
0
votes
1answer
24 views

Is there a way to retrieve the calling template part?

If I include a template part within header.php like this: <?php get_template_part('templates/social-icons'); ?> Is there a way to retrieve the template name header.php within this ...
16
votes
3answers
6k views

Passing a variable to get_template_part

The WP Codex says to do this: // You wish to make $my_var available to the template part at `content-part.php` set_query_var( 'my_var', $my_var ); get_template_part( 'content', 'part' ); But how ...
0
votes
1answer
2k views

How to get_template_part using AJAX?

I'm currently on the Woocommerce archive-product.php template file (say shop page or product category page). On the click of the post (or product), a GET query is added to the title of the same page, ...
1
vote
1answer
130 views

How to use taxonomy term as a value of get_template_part?

I would like to dynamically import different template parts (hardcoded sidebars or navigations) into my layout based on a taxonomy assigned to the post. For instance, this "standard" code works as ...
2
votes
2answers
523 views

Loading page content into a variable in template

On one of my custom templates, I need to do some work with the content before displaying it. Is there a way that I can load this content into a variable rather than just outputting it to the page? ...
0
votes
1answer
56 views

Theme parts path location dump

Few months back I was working on customizing theme that I was assigned to. I remember that I used some function or define something in the config or theme functions file and than it displayed debug ...
1
vote
2answers
737 views

How to pass variables with get_template_part?

I am developing a custom theme and i like to pass some variables to selected files. I am calling the view files from functions.php. $var1 = ; $var2 = ; etc include_once('form-views/view-profile.php')...
1
vote
1answer
69 views

Getting the chosen template when iterating through pages

Im trying print all the pages on a wordpress site. Im using the following code: $args = array( 'post_type' => 'page'); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) : ...
0
votes
1answer
6k views

WP_Query on custom post type not displaying, multiple loops & get_template_part

I'm having problems getting my testimonials to display. On page.php I have a testimonials section. So I have a loop that grabs the content for page.php, and then a get_template_part('content', '...
3
votes
2answers
996 views

Single Page Wordpress Theme - Using page templates

Well I am lost, its late and I have been searching google all night. Heres the problem I am running into. I am trying to create a singe page website using wordpress "pages". How I have initially setup ...
0
votes
1answer
390 views

Problem with Front-Page.php loading recent posts

Hi I this weird problem where i have my custom front-page.php with set page (in Reading Settings) static page. What I want to have is a static page with welcoming message and later 1 recent posts ...