Last active
January 12, 2017 14:02
-
-
Save kish2011/3dbfa5b369a21e806916cfb11ebf23f6 to your computer and use it in GitHub Desktop.
Filter WPJM template locate to use custom templates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* define( 'JOB_MANAGER_FREELANCING_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); | |
* JOB_MANAGER_FREELANCING_PLUGIN_DIR should be defined in your custom plugin | |
* | |
*/ | |
add_filter( 'job_manager_locate_template', 'fl_locate_template', 10, 3 ); | |
/** | |
* Filter WPJM template locate to use custom templates | |
* Now we can over side content-single-job_listing.php template in our custom plugin without moving it to theme. | |
* | |
* @since 0.0.1 | |
* | |
* @see https://wpjobmanager.com/document/template-overrides/#section-2 | |
* @param $template | |
* @param $template_name | |
* @param $template_path | |
* | |
* @return string | |
*/ | |
function fl_locate_template( $template, $template_name, $template_path ){ | |
// print_r($template_name); | |
// Let's check if that file is exist or not. | |
if( 'content-single-job_listing.php' == $template_name && | |
file_exists( JOB_MANAGER_FREELANCING_PLUGIN_DIR . '/templates/' . $template_name ) ){ | |
$template = JOB_MANAGER_FREELANCING_PLUGIN_DIR . '/templates/' . $template_name; | |
} | |
return $template; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment