• Hello
    I realized an error (Warning, below) in the source code of my sitemap related to the travelers-map plugin.

    Warning: Attempt to read property “ID” on null in /home/sndc-ecoclim/reseau/wp-content/plugins/travelers-map/includes/public/cttm-shortcode.php on line 153

    I also found that I had errors in my Search Console: Bad XML tag (see below).

    Le sitemap peut être lu, mais contient des erreurs
    Balise XML incorrecte (5 instances)
    
    Exemples :
    Ligne 1
    Balise parent : urlset
    Tag : br
    
    Ligne 2
    Balise parent : urlset
    Tag : b

    I don’t know if the two issues are related, but how can I resolve the sitemap WARNING?
    Thank you in advance for the help you will give me

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Camille V

    (@socrapop)

    Dear @ctocanier,

    Do you have a travelers map shortcode on this page? Or anywhere on your constant layout (header/footer)?

    After looking at the line mentioned in the error, it seams to be a shortcode with the parameters this_post or centered_on_this.

    I can add a variable check in the next update, but in the meantime you could find where the shortcode is and remove it from this page if not necessary.

    Thread Starter ctocanier

    (@ctocanier)

    Hello,
    Thank you for your reply.
    Yes on the home page of the site I have the shortcode and indeed it contains the parameter centered_on_this.
    I need to keep it to center my map on France because 97% of my markers are located in France but I have others in Guyana and still in New Caledonia.
    If I don’t put this parameter I have the whole world map and I want to focus on France. What should be done in this case?

    Thanks in advance

    Plugin Author Camille V

    (@socrapop)

    I see, do you have the ability to add some javascript code to your website?

    If you can, then you can add the code below to your homepage:

    <script>
    document.addEventListener('cttm_map_loaded', function (e) {
      for (let i = 0; i < cttm_map.length; i++) {
        cttm_map[i].setView([45.30824,5.85554], 10);
      }
    }, false);
    </script>

    This will set the center of the on “La dent de Crolles”, (it’s the example on my documentation), you can play with the latitude/longitude ([45.30824,5.85554]) and zoom level (10) to get what you want.

    Another way would be to add a category or a tag to all the metropolitan posts and pages, so you can filter the map with this category/tag (but the other would disappear)

    I just thought of something else, you could add the post_id=7 parameter on the shortcode, 7 being the id of your homepage (it could be something else, you can find how to find the ID here. That way, even if we are not on the homepage, it would be centered on it.

    I hope this can fix your issue

    Thread Starter ctocanier

    (@ctocanier)

    Hello, thank you for your help. I added the javascript code and removed the parameter in the shortcode and the WARNING disappeared from the source code of my sitemap.

    For errors in my Search Console we will have to wait to see if this has an impact.

    Thanks again

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Warning: Attempt to read property “ID” on sitemap’ is closed to new replies.