WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Displaying most recent post excerpt outside of WordPress (14 posts)

  1. bhrycyk
    Member
    Posted 4 years ago #

    What I am looking to do is to display the title and excerpt of my most recent post on the homepage of my website, which is outside of WordPress. I haven't been able to find any descriptions that have worked for me.

    What do I need to know? What do I need to do?

  2. esmi
    Forum Moderator
    Posted 4 years ago #

  3. bhrycyk
    Member
    Posted 4 years ago #

    Thanks.

    When I input that code into my site and then bring up the page, the entire page comes up blank. No error message, just a blank page.

  4. bhrycyk
    Member
    Posted 4 years ago #

    Here is the HTML code for the page:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    ...and here is the link:
    http://www.brandonhrycyk.com/practice.php

    Your help is appreciated. I'm just not sure what I'm doing incorrectly.

  5. bhrycyk
    Member
    Posted 4 years ago #

    Whoops sorry about the last post, I missed that part in the Forum Rules.

    Anyway, here is the link to the HTML code for the page:

    http://wordpress.pastebin.ca/1844872

    ...and here is the link:
    http://www.brandonhrycyk.com/practice.php

    Your help is appreciated. I'm just not sure what I'm doing incorrectly.

  6. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    move lines 1-4 down just above 12.

    The php include stuff works best right above the </head>

  7. bhrycyk
    Member
    Posted 4 years ago #

    Thanks for your advice, but the page seems to stop loading as soon as it hits the php code.

    Here is the updated code:
    http://wordpress.pastebin.ca/1844904

    When I go to the practice.php page it now loads right up to the point where the php code starts and then nothing loads after that.

    Why might that be happening? Thanks again,

    http://www.brandonhrycyk.com/practice.php

  8. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    You have:
    <?php
    define('WP_USE_THEMES', false);
    require('/blog/wp-blog-header.php');
    ?>

    I have:

    <?php
    define('WP_USE_THEMES', false);
    require('./blog/wp-load.php');
    query_posts('showposts=1');
    ?>

    Notice the . before blog......that may be an issue the dots and slashes are necessary for navigating through your file structure. You have to have the right amount or it wont work. (I have another site that requires ../ to get the php to work

  9. bhrycyk
    Member
    Posted 4 years ago #

    Ok, it looks as if I have had a faulty path to my wp-blog-header.php file. Fortunately, I fixed that but now I am hitting up against a "Fatal Error" message.

    "Call to undefined function: query_posts() in /usr/local/pem/vhosts/213852/webspace/httpdocs/practice.php on line 30"

    What does that mean? How would I call up the most recent posts? I have used the code that I read about in the WordPress codex as well as other places online but keep on receiving this error.

  10. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    query posts goes in your head section, not down below. Look at the example I posted above again

  11. bhrycyk
    Member
    Posted 4 years ago #

    Oops, I forgot to include the most recent code.

    Most recent page code is as follows:

    http://wordpress.pastebin.ca/1844918

    Thanks again,

  12. bhrycyk
    Member
    Posted 4 years ago #

    Thanks RVoodoo,

    I saw that in your post and corrected it...but now I'm getting the error before any of my page loads. So I'm guessing that my query_post code is incorrect.

  13. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    <?php
    define('WP_USE_THEMES', false);
    require('http://brandonhrycyk.com/blog/wp-blog-header.php');
    query_posts('showposts=1'); ?>

    I don't think you can use full url like that here...
    it's got to be a path on your server...

    like
    require('./blog/wp-load.php');

    or
    require('/var/www/example.com/blog/wp-load.php');

  14. bhrycyk
    Member
    Posted 4 years ago #

    I finally figured it out! Thank you RVoodoo for all of your help! My require section was faulty. My WordPress files were installed by my web hosting company so the path to the files weren't as straight forward as it looked in the address bar.

    Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic