I’d also be very interested in this. Ideally as a template override feature similar to how the WordPress Parent/Child theme override works. Modern Tribe’s The Event Calendar does a nice implementation of this by allowing you to place your template overrides in your theme.
@josiahmann I’ve been evaluating various Store Locator plugins and this seems to be the best out there right now, so we’ll probably end up using it. If I find a nice way to do this, without hacking the plugin, I’ll post it here.
@josiahmann,
Figured it out… On line 319 of wp-store-locator.php @tijmensmit includes the apply_filters() function before returning the two template files for the plugin. This allows us to create a filter where we can override the plugin templates with custom templates.
I’ve added this function to my theme to set the paths to the default and “store below” layouts to my overrides:
// Add custom template overrides for the WP Store Locator Templates
add_filter('wpsl_templates', 'foo_wpsl_templates');
function foo_wpsl_templates($templates) {
$templates = array (
array (
'name' => __( 'Default', 'wpsl' ),
'path' => get_stylesheet_directory() . '/wp-store-locator/default.php'
),
array (
'name' => __( 'Show the store list below the map', 'wpsl' ),
'path' => get_stylesheet_directory() . '/wp-store-locator/store-listings-below.php'
)
);
return $templates;
}
That is exactly what I was looking for! Thanks for your response Menslow.
Once I finished coding the 2.0 version I will definitely write proper documentation with code examples 🙂
In the 2.0 version the $templates array will require an id to be present. So you will need to add it after you updated the plugin and save the settings page again to keep your custom template working.
$templates = array(
array(
'id' => 'default',
'name' => __( 'Default', 'wpsl' ),
'path' => WPSL_PLUGIN_DIR . 'frontend/templates/default.php'
),
array(
'id' => 'below_map',
'name' => __( 'Show the store list below the map', 'wpsl' ),
'path' => WPSL_PLUGIN_DIR . 'frontend/templates/store-listings-below.php'
)
);