SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Oct 2001
    Location
    USA
    Posts
    760
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Displaying the most recent 5 posts on a site from wordpress

    I am looking for a way to display the most recent 5 posts from wordpress (title and url only) on an outside website. What is the best way to do this? It actually inst outside of the main domain but it will be in a section different from the blog itself. Any ideas? Thanks in advance guys.

  2. #2
    SitePoint Addict
    Join Date
    Jul 2006
    Location
    Kansas City, MO
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are going to need the other page to parse one of the many feeds offered by wordpress.
    Then just grab the title/url of the most recent 5 entries.

    Code:
    http://example.com/wp-rss.php
    http://example.com/wp-rss2.php
    http://example.com/wp-rdf.php
    http://example.com/wp-atom.php

    Another option would be to write a custom page on the wordpress site that simply serves the recent top 5 stories as intended and your other page displays that page inside an <iframe>

  3. #3
    SitePoint Guru
    Join Date
    Oct 2001
    Location
    USA
    Posts
    760
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thought about the iframe route and altough it is dooable it seems like the cheap rookie way out :-)

    I have a lot of coding experience but none with working directly with feeds, what would be the best way of going about parsing a wordpress feed? Do you know of any good tutorials or online examples of maybe someone already doing this? I cant find anything using good olde G

  4. #4
    SitePoint Guru
    Join Date
    Sep 2000
    Location
    USA
    Posts
    923
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Open a free account in Feedburner.

    Burn the feed from the current blog. That will open an admin panel which will give you the code you need to display as many 'recent posts' as you want.

    The whole process will take you about 5 minutes.
    TheWeighWeWere.com - Weight Loss Success Stories from A to Z!

    oops, I did it again...re-relaunced July '07

  5. #5
    SitePoint Guru
    Join Date
    Oct 2001
    Location
    USA
    Posts
    760
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perfect. Are you talking about the "buzz boost" option?

    "Site overhaul in Feb '07 - what do you think?"

    I think you and your site both look great! Nice job.

  6. #6
    SitePoint Guru
    Join Date
    Sep 2000
    Location
    USA
    Posts
    923
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 321web View Post
    I think you and your site both look great! Nice job.
    Thanks!

    And yes the feedburner text can be removed.
    TheWeighWeWere.com - Weight Loss Success Stories from A to Z!

    oops, I did it again...re-relaunced July '07

  7. #7
    SitePoint Guru
    Join Date
    Oct 2001
    Location
    USA
    Posts
    760
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone know how to get rid of the powered by feedburner link? Maybe this isnt the best solution.

    How else can I achieve this "in house?"

  8. #8
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Just query the database directly from the outside site... it's exactly 4 lines of PHP code :/

  9. #9
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dan Grossman View Post
    Just query the database directly from the outside site... it's exactly 4 lines of PHP code :/
    As not all of us are coding experts and are just learning how to do this, could you please take a moment and share exactly which 4 lines of PHP code would accomplish this?

    Thank you.

    Bailey

  10. #10
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by baileysemt View Post
    As not all of us are coding experts and are just learning how to do this, could you please take a moment and share exactly which 4 lines of PHP code would accomplish this?
    PHP Code:
    //connect to database
    mysql_connect("hostname""username""password");
    mysql_select_db("dbname");

    //retrieve and link to 5 most recent published posts
    $result mysql_query("SELECT * FROM wp_posts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 5");
    while (
    $row mysql_fetch_array($result)) {
      echo 
    "<a href=\"/blog/?p=" $row['ID'] . "\">" $row['post_title'] . "</a>";


  11. #11
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you Dan sorry for my ignorance, but I'm learning!!!

    Bailey

  12. #12
    SitePoint Guru
    Join Date
    Oct 2001
    Location
    USA
    Posts
    760
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so true...over thinking.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •