• Had someone ask if its possible to add a logo / custom image to posts / locations that have a certain category. Wondering if there is a functions approach to do this without having to mess with the plugin code itself.

Viewing 1 replies (of 1 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    If your comfortable with code, then you can use this filter to add additional data to each location. You can use the $store_id to lookup the assigned category, and based on that you can do something like this.

    add_filter( 'wpsl_store_meta', 'custom_store_meta', 10, 2 );
    
    function custom_store_meta( $store_meta, $store_id ) {
    
       // First check if the location is assigned to a category, if so you can do the following.
        
        $store_meta['cat_image'] = 'category image path';
        
        return $store_meta;
    }

    Next use this filter to show it in the search results template like this.

    $listing_template .= "\t\t\t" . '<% if ( cat_image ) { %>' . "\r\n";
    $listing_template .= "\t\t\t" . '<p><img src="<%= cat_image %>"></p>' . "\r\n";
    $listing_template .= "\t\t\t" . '<% } %>' . "\r\n";
    • This reply was modified 4 years, 4 months ago by Tijmen Smit.
Viewing 1 replies (of 1 total)
  • The topic ‘Add image to locations of a certain category’ is closed to new replies.