Strange loop failure
-
I apologize for the uninformative title.
I have set up a php file to simply feed post titles into javascript. Actually, I’ve set up 3 of them. On 2 of the blogs, it works fine. On the other, however, it does not find any posts. Here is the basic code:
<?php require_once('wp-blog-header.php'); while (have_posts()) : the_post(); ?> document.write("<a href='<?php the_permalink() ?>'><?php the_title(); ?></a>"); <?php endwhile; ?>
You can see it working here.
You can see it not working here. (I tested it with an if loop, which returned “nothing found”.)
Now it happens that on our site’s index page, there is another headline feed, which I adapted for the javascript output:
<?php require_once('wp-blog-header.php'); ?> <?php $posts = get_posts('numberposts=10&order=DESC&orderby=post_date'); foreach ($posts as $post) : start_wp(); ?> document.write("<a href='<?php the_permalink() ?>'><?php the_title(); ?></a>"); <?php endforeach; ?>
That works. What could be preventing the original loop code, which works for 2 of the blogs, fail with the 3rd blog?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Strange loop failure’ is closed to new replies.