WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Displaying most recent post excerpt outside of WordPress

[Resolved] Displaying most recent post excerpt outside of WordPress

  • 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?

Viewing 13 replies - 1 through 13 (of 13 total)
  • esmi

    @esmi

    Forum Moderator

    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.

    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.

    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.

    move lines 1-4 down just above 12.

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

    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

    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

    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.

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

    Oops, I forgot to include the most recent code.

    Most recent page code is as follows:

    http://wordpress.pastebin.ca/1844918

    Thanks again,

    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.

    <?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’);

    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!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘[Resolved] Displaying most recent post excerpt outside of WordPress’ is closed to new replies.
Skip to toolbar