WordPress.org

Support

Support » How-To and Troubleshooting » Latest Post on homepage

Latest Post on homepage

  • I just started a website for my productions company, GurwinProductions.com. In the lower left hand corner i want my latest blog post to come up from my blog, (Gurwinproductions.com/blog), right now i have to do it manually. I want to be able to have it automatically update, when i update the blog.

    Any suggestions?

    I tried using rss php parser, and rss to javascript parser, but they didn’t work.

Viewing 13 replies - 1 through 13 (of 13 total)
  • If your home document is a PHP file (i.e. index.php), you could include the wp-blog-header.php file from your blog’s directory, like so:

    <?php require('./blog/wp-blog-header.php'); ?>

    Once this is *available* in the file, you have access to all WordPress features, such as The Loop. To display the last post only, initialize your Loop with by adding this just before it:

    <?php query_posts('showposts=1'); ?>

    More info on query_posts():

    http://codex.wordpress.org/Template_Tags/query_posts

    Why didn’t they? What errors did they give? Be sure to leave the “feed:” out of the feed url. The correct url to your feed is http://www.gurwinproductions.com/blog/?feed=rss2

    Thanks, the change in url made java script one work, but php rss parser still does not work. When I put the script in dreamweaver then preview it in a browser, the following outputs.

    0) { for($i = 0;$i < count($rss_channel[“ITEMS”]);$i++) { if (isset($rss_channel[“ITEMS”][$i][“LINK”])) { print (“\n
    ” . $rss_channel[“ITEMS”][$i][“TITLE”] . “
    “); } else { print (“\n
    ” . $rss_channel[“ITEMS”][$i][“TITLE”] . “
    “); } print (“
    ” . $rss_channel[“ITEMS”][$i][“DESCRIPTION”] . “

    “); } } else { print (“There are no articles in this feed.”); } } print (“Free PHP RSS Parser – RSS Newsfeed Hosting”); ?>

    You could try CG-feedread from http://www.chait.net/index.php?p=238

    I couldn’t get CG-feedread working. Is there anyone here, if I send you my .html file, willing to try to get the blog part working on the homepage?

    Thanks very much!

    The php parser isn’t going to work on a page that has .html extension because your server isn’t going to parse the php in any page without the .php extension. Try renaming your index.html to index.php and see if it works.

    I tried changing the page to .php, but when i load the page (http://www.gurwinproductions.com/index4.php), i get Parse error: parse error, unexpected T_STRING in /home/.mahaut/gurwin/gurwinproductions.com/index4.php on line 185.

    I tried changing the page to .php, but when i load the page (http://www.gurwinproductions.com/index4.php), i get Parse error: parse error, unexpected T_STRING in /home/.mahaut/gurwin/gurwinproductions.com/index4.php on line 185.

    Hmm…You might (and I’m not at all sure) be able to do a php page and call the html page as an include. Like this:

    <?php include ('index.html'); ?>

    I’m not sure how well that will work or if it will solve the unexpected T_STRING error. That unexpected T_STRING error I’ve usually seen when single quotes were used where double quotes were needed or vice versa, but with the code you have on your page there isn’t even a line 185, so it is probably in your RSS parser. If there are single quotes around something (like the feed URL) try changing them to double quotes.

    I tried adding double quotes, and the error now comes up on line 85 (where the change was made).

    Well, then I guess it was the other way around – change those back to single quotes and then go to line 185 and see what’s there.

    I took out what was on line 185, the page kind of loads, but their is a new php error listed.

    (http://www.gurwinproductions.com/index4.php), Warning: fopen(): URL file-access is disabled in the server configuration in /home/.mahaut/gurwin/gurwinproductions.com/index4.php on line 156

    Warning: fopen(http://www.gurwinproductions.com/blog/?feed=rss2): failed to open stream: no suitable wrapper could be found in /home/.mahaut/gurwin/gurwinproductions.com/index4.php on line 156
    could not open XML input

    bump…any suggestions?

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Latest Post on homepage’ is closed to new replies.