WordPress.org

Ready to get started?Download WordPress

Forums

problem with wp-blog-header or have_posts? (2 posts)

  1. jsherk
    Member
    Posted 6 years ago #

    The following test code was working fine up to 2.3.3 but when I upgraded to 2.5 it stopped working. Specifically, it returns nothing, meaning there are no errors but no posts come back either, when it should display titles of the posts!

    <?php
    require('wp-blog-header.php');
    if (have_posts()) : while (have_posts()) : the_post();
    the_title();
    endwhile; else:
    endif;
    ?>

    I don't know what happened since there are no errors coming back!!!

  2. jsherk
    Member
    Posted 6 years ago #

    Okay, just so I know I'm not crazy, try this piece of code:

    <?php
    require('wp-blog-header.php');
    $myid=10; //put a post id here that you know is valid
    $mytest = get_post($myid);
    echo "Known good post id ".$myid." returns: ".$mytest->post_title;
    $mytest = have_posts();
    if ($mytest=="") { $mytest="nothing"; }
    echo " and have_posts() returns: ".$mytest;
    ?>

    If you stick a Post ID number in that you know is valid, it will correctly display the title, yet the have_posts() returns empty!

    Any suggestions anybody?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.