Support » Fixing WordPress » 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 (, 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"?>
    $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) {
    <name><?php the_title(); ?></name>
            } // foreach($posts
          } // if ($posts
        } // foreach($categories
      } // if (categories

    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.