WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] pulling articles into a non wp page (8 posts)

  1. macmiller
    Member
    Posted 9 years ago #

    I've seen others ask this so I have an idea it can be done, but I really don't know where to start. I've got an existing site out there: http://www.coolthaihouse.com and have installed and done some testing on a blog at http://www.coolthaihouse.com/blog. If you look at the coolthaihouse.com page (non wp) there is a section News and Happenings (on the left). I would like to pull 6 articles headlines along with the first sentence of the post and put them here. Can this be done? Any help is appreciated.

  2. moshu
    Member
    Posted 9 years ago #

    You can use this tag http://wiki.wordpress.org/get_posts
    Just modify it for your needs (i.e leave out the "offset", change the "numberposts" to 6) and you are ready to go.
    Make sure you edit the excerpts of your posts, so that it shows the desired portion of the text. (If you do NOT put anything in the excerpt field, it will take a few line from the beginning of your posts.)

  3. macmiller
    Member
    Posted 9 years ago #

    the get_posts is working perfectly. now i only have a question about how to get the date returned as a part of the post which i posted under a new thread.

  4. moshu
    Member
    Posted 9 years ago #

    Try adding in the code that you got from the get_posts
    start_wp()
    ie, something like this (I hope it will show up :)
    <?php
    $posts = get_posts('numberposts=1&offset=0');
    foreach ($posts as $post) : start_wp(); ?>
    <?php the_date(); ?>
    " rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?>
    <?php the_excerpt(); ?>
    <?php
    endforeach;
    ?>

    Of course you can remove the permalink anchor, though it wouldn't make too much sense.

  5. macmiller
    Member
    Posted 9 years ago #

    yes that worked! I also found, interestingly, that a call to the_time returns a time with or without the start_wp.
    thankz.

  6. moshu
    Member
    Posted 9 years ago #

    Glad that finally you worked out. Yes, it seems the_time works even outside The Loop

  7. curious
    Member
    Posted 9 years ago #

    update for the benefit of future visitors, blogging novices like me: if you want to include an RSS feed in an ordinary static webpage, it's easily done. Just do a web search for "RSS javascript" (without the quotes) and you should find many many sites offering to generate a few lines of javascript that you can insert into an ordinary .html page. Works great so far.
    Here's one site I like:
    http://jade.mcli.dist.maricopa.edu/feed/

  8. Ruby Sinreich
    Member
    Posted 9 years ago #

    I have been using something like <?php $posts = get_posts('category=7&numberposts=1&order=DESC&offset=0'); foreach ($posts as $post) : ?> on my 1.3 development blog. It worked fine for a while and then it stopped. Anyone have any guesses as to what would make this happen? Maybe something with updated beta code...?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.