Title: XML not generating
Last modified: August 19, 2016

---

# XML not generating

 *  [awx2d](https://wordpress.org/support/users/awx2d/)
 * (@awx2d)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/xml-not-generating/)
 * Hi
    I’m generating a XML file using the following code but the xml only displays
   when I’m logged in, once I log out of the admin the code no longer works, any
   ideas? I have a funny feeling it is to do with the id not being passed, is there
   a way to manually pass this or to use another variable to generate the xml?
 *     ```
       <?php
       require('./wp-config.php');
       header('Content-type: text/xml; charset=utf-8');
   
       function ssp_fetch_images($postid) {
           global $wpdb;
           return $wpdb->get_results("SELECT guid, post_title, post_content, post_excerpt FROM $wpdb->posts WHERE post_parent = $postid AND post_mime_type = 'image/jpeg'");
       }
   
       if(isset($_GET['cat'])) {
       $cat = $_GET['cat'];
       $query = "cat=$cat&showposts=1000";
       } else {
       $query = "showposts=1000";
       } ?>
       <gallery>
           <?php $gallery = new WP_Query($query);
           while ($gallery->have_posts()) : $gallery->the_post(); ?>
           <album id="<?php echo htmlspecialchars($post->post_title); ?>" title="<?php echo htmlspecialchars($post->post_title); ?>" description="<?php echo htmlspecialchars($post->post_excerpt); ?>" tn="<?php $key=($post->post_title); echo get_post_meta($post->ID, $key, true); ?>">
               <?php $images = ssp_fetch_images($post->ID);
               foreach($images as $image) { ?>
               <img src="<?php echo $image->guid; ?>" tn="<?php echo $image->guid; ?>" title="<?php echo htmlspecialchars($image->post_title); ?>" caption="<?php echo htmlspecialchars($image->post_title); ?>" />
               <?php } ?>
           </album>
           <?php endwhile; ?>
       </gallery>
       ```
   

Viewing 1 replies (of 1 total)

 *  [scribblerguy](https://wordpress.org/support/users/scribblerguy/)
 * (@scribblerguy)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/xml-not-generating/#post-784344)
 * Have you tried requiring `wp-blog-header.php` instead of `wp-config.php`?
 * With wp-blog-header.php, you can use the normal WP template tags.

Viewing 1 replies (of 1 total)

The topic ‘XML not generating’ is closed to new replies.

 * 1 reply
 * 2 participants
 * Last reply from: [scribblerguy](https://wordpress.org/support/users/scribblerguy/)
 * Last activity: [17 years, 11 months ago](https://wordpress.org/support/topic/xml-not-generating/#post-784344)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
