Site icon Anthony Carbon

Override InWave Jobs template to the current theme

Override InWave Jobs template to the current theme is little bit hard for the WordPress beginners so I want to write tutorials that can help them solving this issue. Before that, just a little background for InWave Jobs.  InWave Jobs is created by inwavethemes which I beleive many WordPress users is now using this, easy and very powerful plugin. To check more info about this plugin, just visit their website http://inwavethemes.com/inwavejob.

Ok, overriding their template files is not yet setup by InWave Jobs (maybe soon on their latest version). You have to code it manually so the overriding will works perfectly. As you can see in the picture below, the function that controls all templating is for plugin file path only.

I’m not saying I am 100% correct but that is how I judge the code. As you can see, it has `apply_filters` where we can override the default template file path. That’s the key to override the template files.

$template = apply_filters( 'iwj_get_template_part', $template, $slug, $_args );

Using functions.php of you current theme, let’s copy and paste the codes below to your functions.php

add_filter( 'iwj_get_template_part', 'iwj_get_template_part_temphub', 10, 3 );
function iwj_get_template_part_temphub( $template, $slug, $_args ){
	if( file_exists( get_stylesheet_directory() . "/iwjob/templates/{$slug}.php" ) ){
		$template = get_stylesheet_directory() . "/iwjob/templates/{$slug}.php";
	}
	return $template;
}

This will read all templates in the current theme under `/iwjob/templates/` you can now made changes without affecting the main plugin.

This is the InWave Jobs plugin folder templates.

This is the complete template override in the current theme.

And that’s it, happy conding everyone 🙂

Exit mobile version