• Resolved bhrycyk

    (@bhrycyk)


    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)
  • Thread Starter bhrycyk

    (@bhrycyk)

    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.

    Thread Starter bhrycyk

    (@bhrycyk)

    Here is the HTML code for the page:

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

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

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

    Thread Starter bhrycyk

    (@bhrycyk)

    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:

    https://wordpress.pastebin.ca/1844872

    …and here is the link:
    https://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>

    Thread Starter bhrycyk

    (@bhrycyk)

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

    Here is the updated code:
    https://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,

    https://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

    Thread Starter bhrycyk

    (@bhrycyk)

    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

    Thread Starter bhrycyk

    (@bhrycyk)

    Oops, I forgot to include the most recent code.

    Most recent page code is as follows:

    https://wordpress.pastebin.ca/1844918

    Thanks again,

    Thread Starter bhrycyk

    (@bhrycyk)

    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('https://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’);

    Thread Starter bhrycyk

    (@bhrycyk)

    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 ‘Displaying most recent post excerpt outside of WordPress’ is closed to new replies.