Extends the WordPress get_template_part() function by adding the current site location onto the end automatically. This is useful if you want to avoid using complicated WordPress conditional tags with case or elseif code in your theme files to detect location.


part – the base filename of the template part you wish to use.

Return values

Displays/executes specified PHP file from your child theme directory.

wfx_get_template_part('part=custom-one'); will use the following file if exists in your child theme directory:
custom-one-home.php – Homepage (posts or static page) view
custom-one-category.php – Category view
custom-one-tag.php – Tag view
custom-one-search.php – Search results view
custom-one-date.php – Date archive view
custom-one-author.php – Author view
custom-one-taxonomy.php – Taxonomy view
custom-one-archive.php – Archive view
custom-one-attachment.php – Attachment view
custom-one-single.php – Single post view
custom-one-page.php – Page view
custom-one-404.php – 404 view

If file doesn’t exist, custom-one.php file will be used instead.


//Example 1
//In your child theme functions.php file
//Include file custom-one.php after main content using hook
//Will use location aware template parts if available
function my_wfx_example_function(){
add_action ('wfmain_after_main_content','my_wfx_example_function');
//Example 2
//Code directly into your child theme file eg loop-content.php
//Include file extra-content.php on page view specific hook
//Will use location aware template parts if available


The best way to code custom layout code is example 1 – using Wonderflux hooks keeps layout code like this all together in your child theme functions.php file instead of repeated in multiple theme files and allows you to use any one of over 100 hooks available to you in Wonderflux.

Example 2 is useful in content template parts like header-content.php and loop-content.php to split up large, complex files.

This function documentation was last modified on: August 10, 2011 by Jonny