Viewing 2 replies - 1 through 2 (of 2 total)
  • I was able to do this by adding the following code to my functions.

    add_filter( 'wpsl_listing_template', 'custom_listing_template' );
    
    function custom_listing_template() {
    
        global $wpsl_settings;
    
        $listing_template = '<li data-store-id="<%= id %>">' . "\r\n";
        $listing_template .= "\t\t" . '<div>' . "\r\n";
        $listing_template .= "\t\t\t" . '<p><%= thumb %>' . "\r\n";
        $listing_template .= "\t\t\t\t" . wpsl_store_header_template( 'listing' ) . "\r\n";
        $listing_template .= "\t\t\t\t" . '<span class="wpsl-street"><%= address %></span>' . "\r\n";
        $listing_template .= "\t\t\t\t" . '<% if ( address2 ) { %>' . "\r\n";
        $listing_template .= "\t\t\t\t" . '<span class="wpsl-street"><%= address2 %>/span>' . "\r\n";
        $listing_template .= "\t\t\t\t" . '<% } %>' . "\r\n";
        $listing_template .= "\t\t\t\t" . '<span>' . wpsl_address_format_placeholders() . '</span>' . "\r\n";
        $listing_template .= "\t\t\t\t" . '<span class="wpsl-street"><%= formatPhoneNumber( phone ) %></span>' . "\r\n";
        $listing_template .= "\t\t\t" . '</p>' . "\r\n";
    
        $listing_template .= "\t\t" . '</div>' . "\r\n";
    
        if ( !$wpsl_settings['hide_distance'] ) {
            $listing_template .= "\t\t" . '<%= distance %> ' . 'miles away.' . "\r\n";
        }
    
        $listing_template .= "\t\t" . '<%= createDirectionUrl() %>' . "\r\n";
        $listing_template .= "\t" . '</li>' . "\r\n";
    
        return $listing_template;
    }
    Plugin Author Tijmen Smit

    (@tijmensmit)

    @alessioangeloro

    You are confusing two things. The first part of the code here https://codeshare.io/HWOSl is the base template for the store locator, the second part is the template code used by https://underscorejs.org/ to show the location details.

    Both need to be modified in different files. If you want to modify the template that shows the location details, then you need to use this filter. The code example from @gr8whtd0pe does just that.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Template Override’ is closed to new replies.