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)
Viewing 1 replies (of 1 total)
- The topic ‘XML not generating’ is closed to new replies.