Navigation überspringen

[Gelöst] Marker not displaying in loop with address field

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem: I have a View that includes an address field in the loop, but none of the markers are appearing on the map. If I display a map on the single post containing the same address field, the marker appears as expected.

Solution: In this case, some custom code is causing the map ID to be modified. This breaks the map initialization code on the page with the View. Disabling this get_the_excerpt filter code fixes the problem.

This support ticket is created vor 5 Jahren, 12 Monaten. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Dieses Thema enthält 7 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Daniel vor 5 Jahren, 11 Monaten.

Assistiert von: Christian Cox.

Author
Artikel
#1181679

Hello,

on my site toolset maps works in the backend and in single post, for example:
versteckter Link

I use an adressfield as data-source.

When I try to add several markers in a loop, I only see a part of Africa:
versteckter Link

The page is in a multisite on PHP 7.1. The three required Google maps APIs are activated. I tried to add it like you described in your documentation, but can't get it running. Any idea?

Best, Daniel

#1181706

Please provide login credentials in the private reply fields here.

#1181743

Thank you. Unfortunately I was unable to figure this out by the end of my day, but I will be available again on Sunday to continue investigating. If you need more immediate assistance, feel free to start a new ticket and request assistance. Thanks!

#1183097
Screen Shot 2019-01-13 at 11.02.21 AM.png

Okay I was able to get a clone of the whisky site working as a standalone site in my local environment. I deactivated all drop-ins, caching systems, and plugins except Types, Views and Maps. I kept the GeneratePress theme active, and updated to the latest WordPress. The map loaded as expected for me, with clusters over the UK/Ireland area and over Japan - see screenshot. So next, I proceeded to activate other plugins. Since I'm running a standalone site, I didn't activate any of the multisite plugins. I'm not able to reproduce the problem locally. So that leads me to believe the problem could be one of the following:
1. A conflict with one of the multisite plugins used on your multisite installation
2. A problem with server-side caching
3. A configuration problem in your .htaccess or .user.ini files on the server

Do you have a staging area set up where we can try deactivating plugins? Since this is a multisite installation, making those kinds of changes can have a significant impact on a live site.

#1183104

Hello Christian,

thanks a lot. I have no staging environment, but I'll disable the multisite-plugins temporarily and come back here.

Best, Daniel

#1183111

Hello Christian,

thanks so much! I found the error. When I deactivated code snippets plugin it worked. But I have it running in other multisites, so it must have been a problem with one of the snippets itself.

So I deactivated them also one on one and found the evildoer. It is a snippet, which I use to allow some html in excerpts in GeneratePress.

remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'generate_improved_trim_excerpt');
function generate_improved_trim_excerpt($text) {
    global $post;
    if ( '' == $text ) {
        $text = get_the_content('');
        $text = apply_filters('the_content', $text);
        $text = str_replace(']]>', ']]>', $text);
        $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
        $text = strip_tags($text, '<p>,<br>,<strong>,<em>,<img>');
        $excerpt_length = 55;
        $words = explode(' ', $text, $excerpt_length + 1);
        if (count($words)> $excerpt_length) {
            array_pop($words);
            array_push($words, '[...]');
            $text = implode(' ', $words);
        }
    }
    return $text;
}

But I don't know why it collides with maps plugin.

Best from Germany

Daniel

#1183164

It seems that the get_the_excerpt filter code changes the map ID somehow, and I'm not sure why. In my local system an extra "-1" is appended to the ID, which breaks the map initialization code.

js-wpv-addon-maps-render-map-9-1

The line that applies the_content filter seems to be responsible. Not sure why exactly.

#1183385

Thanks a lot again! I'll leave it as it is now without html in excerpt.