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
15 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
15 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
16 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
30 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 ...
5
votes
3answers
130 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
0answers
28 views

get template part

we have a dashboard for users. it's like front-end my page which is listed For example we have sub menus on this page. change my profile list of my posts list of my comments payment history my ...
0
votes
3answers
44 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
52 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
0answers
90 views

How to get/display specific WP page with beloning page template in DIV (fullPage.js)

I've recently been trying out the really neat JavaScript snippet for fullPage-design from Alvaro Trigo. http://www.alvarotrigo.com/fullPage/. I use it togheter with WordPress with the purpuse of ...
0
votes
1answer
30 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
64 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
0answers
42 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
34 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
76 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
38 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
80 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
0answers
15 views

get_template_part within plugin [duplicate]

TL;DR: How do I use something similar to get_template_part from within my plugin? I've created a custom filtering course listing for a school that queries posts to display what matches the user's ...
0
votes
2answers
145 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
140 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
82 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
1answer
113 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
121 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
132 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
115 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
77 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
95 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
52 views

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

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 ...
0
votes
1answer
64 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
0answers
54 views

Use Custom Post Types, Get Template Part or Both when dealing with Taxonomies?

My Question headline might suck in which case any suggestions would be great:) I am having an issue with understanding in which context i should use and create a content-page.php vs. just calling in ...
0
votes
1answer
78 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' ); ...
0
votes
1answer
145 views

get_template_part() doesn't work

I use get_template_part() function to get theme options page content like this: function setup_theme_admin_menus() { add_theme_page( "Theme Options", "Theme Options", "read", "theme_options", ...
0
votes
1answer
541 views

Where is the template for the 'standard' format of a post in the theme twentythirteen?

I have selected the 'standard' format for a post: I am now trying to edit the layout of posts, in index.php I can see the following line: get_template_part( 'content', get_post_format() In the ...
0
votes
2answers
174 views

Too many get_template_parts?

For a lot of my site I'm using get_template_part mostly because I had coded most of it in html/css first and it just seemed easier to call each part as I saw fit. My question is, basically, will this ...
0
votes
3answers
252 views

Get template part based on custom taxonomy term

I have a custom post type and I'm trying to call up different variations of the navigation based on the custom taxonomy slug. I've done this fairly easily with normal posts, like so: <?php ...
0
votes
0answers
89 views

query_post while (have post) get_template_part()?

My goal: Is to give the user the ability, if they so choose, to create a new category. I have the current categories saved in a separate php file and call them in using get_template_part(), there ...
1
vote
1answer
34 views

Valid HTML in Template Part

in a custom plugin I have a WPQuery, which looks like the following: $sticky = get_option( 'sticky_posts' ); $args = array( 'post_type' => 'mission', 'ignore_sticky_posts' ...
0
votes
1answer
3k views

Correct way to use get_template_part() and get_post_format() with custom post types?

I have a custom post type of 'competitions'. In order to customise the display for this CPT in, for example, category listings I am doing the following: Create a category-competitions.php file ...
0
votes
1answer
57 views

Is it possible to have a Theme with built-in physical page files?

I am creating a theme and was thinking if it would be possible to create pages within my theme folder that would reflect the wordpress url + path. So for example I could when accessing: ...
1
vote
1answer
35 views

Problems with loop

I have this loop in my index.php: <?php if (have_posts()) : while (have_posts()) : get_template_part( 'post' ); endwhile; endif; ?> which calls ...
0
votes
1answer
111 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
2answers
70 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 ...
2
votes
1answer
976 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
1answer
231 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 ...
7
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 ...
1
vote
2answers
311 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 ...
1
vote
1answer
205 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
278 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
213 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
2answers
126 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
432 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 = ...