WordPress.org

Ready to get started?Download WordPress

Forums

GET_POSTS (5 posts)

  1. macmiller
    Member
    Posted 9 years ago #

    Newbie: I'm playing with getting blog extracts into a non wp page on my site (coolthaihouse.com). It was recommended to use get_posts. I've been playing with a small test file to see how this get_posts works. The file is at coolthaihouse/blog/wptest.php (and the text follows). The other php calls are just there to show they are 'working'. Everything returns what it should, except the get_posts doesn't seem to return anything. Can someone take a quick look at this and let me know what i need to do to get this to work??? and thakz....
    <?php
    /* Don't remove this line. */
    require('./wp-blog-header.php');
    ?>
    <?php bloginfo('info'); ?>
    <?php wp_get_archives('monthly','all','option','','',true); ?>
    <?php get_posts('numberposts=10&offset=1'); ?>
    <?php get_calendar('1'); ?>

  2. macmiller
    Member
    Posted 9 years ago #

    nevermind. i figured it out already! the get posts is working but doesn't display until encased in something like this (as it says on the wiki)!!!!!

      <?php
      $posts = get_posts('offset=1');
      foreach ($posts as $post) :
      ?>

    • "><?php the_title() ?> --- <?php the_excerpt() ?>
    • <?php
      endforeach;
      ?>

  3. macmiller
    Member
    Posted 9 years ago #

    /

      <?php
      $posts = get_posts('offset=1');
      foreach ($posts as $post) :
      ?>

    • "><?php the_title() ?> --- <?php the_excerpt() ?>
    • <?php
      endforeach;
      ?>

    /

  4. moshu
    Member
    Posted 9 years ago #

    No need to start a new thread!
    Just continue where you've asked first: http://wordpress.org/support/3/13294

  5. macmiller
    Member
    Posted 9 years ago #

    yes, correct, the post should have gone to http://wordpress.org/support/3/13294. cyber-spanking noted:) and sorry for the duplicate post here.
    the code which i was trying to display above (or refer to 13294) is something like this:
    <?php
    $posts = get_posts('numberposts=2&offset=0');
    foreach ($posts as $post) : start_wp();
    ?>

  6. <?php the_date('','','',TRUE);?>
    ">
    <?php the_title() ?>
    ---
    <?php the_excerpt() ?>

  7. <?php
    endforeach;
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.