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
19 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
39 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
12 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
31 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
57 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
48 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
34 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
23 views

content-aside.php not being recognised

I am new to WordPress and I have hit a very frustrating block. I am trying to set up post formats, which I have done, and can select from the admin panel, but none of them will recognise my ...
0
votes
0answers
69 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
91 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
33 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
51 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
30 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
21 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 ...
9
votes
2answers
809 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
866 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, ...
0
votes
1answer
75 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 ...
1
vote
2answers
221 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
39 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 ...
0
votes
0answers
98 views

Nested get_template_part / WP_Query – How should I do this?

I'm running a loop that runs a certain get_template_part, and that template file itself should then run another get_template_part, with the purpose to get some posts, is this even possible? At the ...
1
vote
2answers
486 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 ...
0
votes
1answer
48 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
2k 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', ...
2
votes
2answers
608 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
260 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 ...
0
votes
1answer
28 views

How can have a conditional template tag based on the main loop within a secondary loop with new WP_Query(), using get_template_part()

What is the best practice methodology for referencing the main loop from within the context of a secondary loop within a partial called via get_template_part()? For example, say my homepage contains ...
0
votes
0answers
19 views

How to unregister sidebar for template_part?

Can you help me please? I have this code in my index.php: php get_sidebar(); And I have a template_part 'loop-fullwidth', which I call in index.php. I need to register sidebar for index.php and ...
0
votes
1answer
169 views

Is it possible to call a template file inside wysiwyg editor? And how?

Is it possible to call a template file, say for example mycustomtemplate.php inside the default Wordpress WYSIWYG editor? I had this content. My team (This is my content inside the WYSIWYG) then I ...
7
votes
4answers
1k 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 ...
0
votes
3answers
313 views

How can I see what template parts are being called for rendering the viewable page?

I have a theme where the developer used get_tempalate_part() a lot, and these parts are scattered across theme subdirectories as well as in directories in a plugin that was created to assist with the ...
0
votes
1answer
243 views

Get template part vs locate template function

I'm in single.php where I'm trying to get related-posts.php template. The problem is that when using get template part the related-posts.php isn't getting custom taxonomy name from single.php in ...
0
votes
1answer
57 views

Passing a variable from the archive page to the default template

I have created an archive page that will display the whole content of list of posts. The individual post content output should be managed from a specialized that I will integrate using the WP built-in ...
0
votes
2answers
202 views

The use of get_template_part() returns 'invalid argument' loading options

I would like to avoid the include_once() in order to remove one INFO using Theme Check, and when I try to load my Options page using get_template_part('custom-options'); it returns the message: ...
1
vote
1answer
195 views

Change the file path on get_template_part via plugin

I'm trying to make a plugin that will change the behavior of a theme. In the theme file I have a get_template_part('libs/templates/user_menu');. I want to make my plugin "force" the ...
0
votes
1answer
72 views

Use of IF statement in Header file

I have a custom page template created. When I load my page, it shows the header logo of the mainpage but what I want to achieve is for each custom template created, I want it to only show its own ...
0
votes
2answers
122 views

Re-using single CPT code with get_template_part?

Wordpress newbie, here. I've created a custom post type, using CPT UI, named "menus". Later created single instances of that "menus" CPT, directed by a "single-menu" template. So here's my hierarchy ...
0
votes
1answer
40 views

Is this correct get_template_part() in WordPress?

I just want to show the slider structure if it has posts... is this correct? <?php if ( (have_posts() ) { get_template_part('slider'); } ?> I think that works but I'm not sure if is ...
1
vote
3answers
144 views

Some doubts about how to show posts in a custom theme?

I am pretty new in WordPress theme development and I have some doubt about this WP function used to show my post in the homepage: <?php if ( have_posts() ) : // Start the ...
0
votes
2answers
309 views

Template tags vs get_template_part() vs functions.php

When to use template tags and when to use get_template_part() and when to use function.php? I am confused at them. For example, if I want to show related portfolios under single portfolio, I can ...
0
votes
1answer
359 views

get_template_part() to render single page Theme

I´m developing a single page theme and want to render all pages with their respective templates on a single page. I know I could make a query and write the markup for the respective page, but I prefer ...
0
votes
2answers
91 views

Including template pages within another template?

I've created a vertical page template which displays stacked sections (which are simply the content from other wordpress pages). I am having problems displaying the contents of pages which are ...
0
votes
2answers
1k views

How to include a file using get_template_part() in a plugin?

A very simple question may be, but I'm struggling. In theme development, I worked with get_template_part() many times, and I understand its basics. But when I's developing a plugin, I wondered using ...
0
votes
1answer
330 views

get_template_part function and add images

Added this function in any page: get_template_part('recent', 'posts'); And: if(have_posts()){ while(have_posts()){ the_post(); ?> <div class="site-content clearfix"><?php ...
0
votes
2answers
256 views

Get Specific Template Part if Custom Field is Some Value

I have a problem and I don't know how to solve it. I tried some solutions but I failed since I am not good programer. I also tried to find a solution, but there is no similar question asked. So... ...
0
votes
1answer
163 views

Tag page only display 10 posts

I've had a problem with this for quite some time now and cannot for the life of me figure it out. I am using Multi-site and not sure if that has anything to do with it or not, so keep that in mind. ...
0
votes
1answer
131 views

get_template_part() isn't loading author information

Using get_template_part() I parted some of my theme's common post templates. My post template is content-general.php. Without parting thing is going fine. But just after parting the template — ...
0
votes
1answer
170 views

How return normal search result using wp_ajax action for wordpress

I want the normal search result to be available when using the wp_ajax action. Is there a way to do execute the normal WP_Query for the parameters that are available in the current request? This is ...
0
votes
2answers
57 views

Is there a way to call on just the content of a Page without actually using that Page? [closed]

The question sounds weird i know, but what i'm trying to do is add a gravity form into a template that i made. But all of their tutorials seem to be more along the lines of adding a form to a page ...
1
vote
1answer
212 views

Get_template_part inside a folder

So I've the following code in order to search for templates inside a custom theme I'm working on: <?php $my_theme = wp_get_theme(); get_template_part( 'masthead', $my_theme->Template); ?> ...
0
votes
1answer
127 views

Is “get_template_part” hierarchy possible?

I'm build a custom Wordpress theme using get_template_part to call tiny bits of code. I have file called "masthead.php" that is called using this code: <?php get_template_part( 'masthead' ); ...