Featured image not getting displayed ibn
-
Hello,
I am using below provided custom code but it is not displaying featured image in the info window.
// ✅ Add thumbnail URL to the store data passed to JS
add_filter(‘wpsl_frontend_store_data’, function($store_data, $store_id) {
$thumbnail_url = wp_get_attachment_url(get_post_thumbnail_id($store_id));
$store_data[‘post_thumbnail_url’] = $thumbnail_url ? $thumbnail_url : ”;
return $store_data;
}, 10, 2);// ✅ Customize Info Window Template
add_filter(‘wpsl_info_window_template’, ‘custom_info_window_template’);
function custom_info_window_template() {
global $wpsl_settings, $wpsl;$info_window_template = '<div data-store-id="<%= id %>" class="wpsl-info-window">' . "\r\n"; // Thumbnail $info_window_template .= "\t\t\t" . '<% if ( typeof post_thumbnail_url !== "undefined" && post_thumbnail_url ) { %>' . "\r\n"; $info_window_template .= "\t\t\t" . '<img src="<%= post_thumbnail_url %>" alt="Store Image"/>' . "\r\n"; $info_window_template .= "\t\t\t" . '<% } %>' . "\r\n"; // Address $info_window_template .= "\t\t" . '<p>' . "\r\n"; $info_window_template .= "\t\t\t" . wpsl_store_header_template() . "\r\n"; $info_window_template .= "\t\t\t" . '<span><%= address %></span>' . "\r\n"; $info_window_template .= "\t\t\t" . '<% if ( address2 ) { %>' . "\r\n"; $info_window_template .= "\t\t\t" . '<span><%= address2 %></span>' . "\r\n"; $info_window_template .= "\t\t\t" . '<% } %>' . "\r\n"; $info_window_template .= "\t\t\t" . '<span>' . wpsl_address_format_placeholders() . '</span>' . "\r\n"; $info_window_template .= "\t\t" . '</p>' . "\r\n"; // Phone $info_window_template .= "\t\t" . '<% if ( phone ) { %>' . "\r\n"; $info_window_template .= "\t\t" . '<span><strong>' . esc_html($wpsl->i18n->get_translation('phone_label', __('Phone', 'wpsl'))) . '</strong>: <%= formatPhoneNumber( phone ) %></span>' . "\r\n"; $info_window_template .= "\t\t" . '<% } %>' . "\r\n"; // Fax $info_window_template .= "\t\t" . '<% if ( fax ) { %>' . "\r\n"; $info_window_template .= "\t\t" . '<span><strong>' . esc_html($wpsl->i18n->get_translation('fax_label', __('Fax', 'wpsl'))) . '</strong>: <%= fax %></span>' . "\r\n"; $info_window_template .= "\t\t" . '<% } %>' . "\r\n"; // Email $info_window_template .= "\t\t" . '<% if ( email ) { %>' . "\r\n"; $info_window_template .= "\t\t" . '<span><strong>' . esc_html($wpsl->i18n->get_translation('email_label', __('Email', 'wpsl'))) . '</strong>: <%= formatEmail( email ) %></span>' . "\r\n"; $info_window_template .= "\t\t" . '<% } %>' . "\r\n"; // Example: Custom static text $info_window_template .= "\t\t" . '<p>Closed Open</p>' . "\r\n"; // Opening Hours if (!$wpsl_settings['hide_hours']) { $info_window_template .= "\t\t\t" . '<% if ( hours ) { %>' . "\r\n"; $info_window_template .= "\t\t\t" . '<p><%= hours %></p>' . "\r\n"; $info_window_template .= "\t\t\t" . '<% } %>' . "\r\n"; } // Actions (Directions, More Info, etc.) $info_window_template .= "\t\t" . '<%= createInfoWindowActions( id ) %>' . "\r\n"; $info_window_template .= "\t" . '</div>' . "\r\n"; return $info_window_template;}
Please let me know if you have any idea about this issue.
Thank you.
The topic ‘Featured image not getting displayed ibn’ is closed to new replies.