Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 21376

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.

19 votes
Accepted

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

get_template_part is a theme function. You can't load plugin files with that function. Take a look at the source and you will notice the work is done by locate_template. Look at that source and you wi …
s_ha_dum's user avatar
  • 65.5k
4 votes

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

What you've done will include content-competitions-<post-format>.php. I don't know if that is what you want, but that is correct as far as structure goes. I also don't know what you mean by "to chan …
s_ha_dum's user avatar
  • 65.5k
2 votes

Get template part based on custom taxonomy term

The "custom taxonomy slug", in your case, would be prodcat but based on your code I assume that you mean the individual term slugs. Now, get_the_terms() will return all terms assigned to the post bu …
s_ha_dum's user avatar
  • 65.5k
2 votes

Echo a shortcode div after every 3 posts

First, let's clean up this tag SPAM nightmare so we can read it and then simplify the code: function adinserter() { return 'abcdefg'; } if (have_posts()) { $count = 0; while (have_posts()) { …
s_ha_dum's user avatar
  • 65.5k
1 vote

How do I display an image before the first post of the loop when I'm using get_template_part?

You are incrementing your $count variable outside of the part of the Loop that is running through the posts. You code needs to increment the counter inside the while. $count = 0; if ( have_posts() ) …
s_ha_dum's user avatar
  • 65.5k
1 vote

Using get_template_part to retrieve a template file based on current post type

Your problem here is partly just bad PHP and partly a misunderstanding of get_template_part. You are literally asking for a file named "parts/get_post_type( $post )". Closer to right would be... ge …
s_ha_dum's user avatar
  • 65.5k
0 votes
Accepted

When using shortcode, content stops generating after the_content

This is a bit of a guess, but you are running a secondary query inside the Loop (by way of the shortcode). That is going to alter some variables that subsequent code may depend upon, such as $post. …
s_ha_dum's user avatar
  • 65.5k