Title: Add WordPress code in XML file
Last modified: August 19, 2016

---

# Add WordPress code in XML file

 *  [Antonin](https://wordpress.org/support/users/antonin/)
 * (@antonin)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/add-wordpress-code-in-xml-file/)
 * Hi,
 * I am working on a project to place Markers on a google map based on informations
   from certain posts (I will put the latitude and longitude infos on custom fields
   later).
 * I am following this idea ([http://articles.sitepoint.com/article/google-maps-api-jquery](http://articles.sitepoint.com/article/google-maps-api-jquery)),
   slightly modified to work with wordpress. I transformed the XML file of the markers
   in php format to insert my wordpress query. Although I can make basic php code
   works (like an “echo”), I cannot retrieve the data from my wordpress posts.
 * The javascript which places the markers is called in the header and the xml is
   called by the javascript.
 * Here is my code at the moment for that specific php/xml file:
 *     ```
       <?xml version="1.0"?>
   
       <markers>
   
       <?php 
   
       $categories = get_categories('child_of=1');
       if ( $categories ) {
         foreach($categories as $category) {
             $posts=get_posts('showposts=1&cat='. $category->term_id);
             if ($posts) {
   
               foreach($posts as $post) {
                 ?>
   
       		  <marker>
       <name><?php the_title(); ?></name>
       <address>text</address>
       <lat>17.75033553</lat>
       <lng>83.25067267</lng>
       </marker>
   
                 <?php
               } // foreach($posts
             } // if ($posts
           } // foreach($categories
         } // if (categories
   
       ?>
   
       </markers>
       ```
   
 * I don’t know what I’ve missed.
 * thanks in advance for any help/advice I can get.

The topic ‘Add WordPress code in XML file’ is closed to new replies.

## Tags

 * [xml](https://wordpress.org/support/topic-tag/xml/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Antonin](https://wordpress.org/support/users/antonin/)
 * Last activity: [16 years, 2 months ago](https://wordpress.org/support/topic/add-wordpress-code-in-xml-file/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
