WordPress.org

Forums

Recent Posts for a non-WP php page (11 posts)

  1. amelzak
    Member
    Posted 10 years ago #

    Is there a hack or plugin that allows Recent Posts block to be shown on a page that is not in the WP folder?

    For example I have my WP account in a folder called /wp/.

    But I want to show recent posts from my WP account in my main index.php file in the root of the website.

    Is there any way to do this? Thanks!

  2. Kafkaesqui

    Posted 10 years ago #

    ~dupe~

  3. Kafkaesqui

    Posted 10 years ago #

    To turn any php page into a WordPress one, make sure this is at the very start of the page:

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

    From there you can use any WP template tags, etc. If you just want to provide the title and link to your recent posts, check out the get_archives() tag and the 'postbypost' value for the type parameter, and the limit parameter:

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

  4. davidchait
    Member
    Posted 10 years ago #

    You can also use the rss feed using an aggregator like CG-FeedRead in order to link to your own site from another page, without having to directly include WP. Also good if you only update your site once every day or two, as the caching system will prevent WP from doing its full lookup/setup for every load of your external page.

    -d

  5. TheWorldofDan
    Member
    Posted 10 years ago #

    Thank you, I'll have a look/play :)

  6. breger
    Member
    Posted 10 years ago #

    Maybe a stupid question this but...can this be done in an HTML page or would I have to change the frontpage of my site (which is in HTML) to a PHP page?

  7. davidchait
    Member
    Posted 10 years ago #

    Hmmm. Aside from some kind of javascript invokation (which seems to be one approach), not sure how you'd include into raw HTML (I'm sure there's methods).

    CG-FeedRead does its caching into raw HTML code/files, and if the cache time hasn't expired it literally just includes the cache file and returns. In theory, if inside your site's homepage or something you were 'touch' the feed you want to publish (by doing a getSomeFeed call, but not echoing the results...), you could then find the HTML file output from CG-FeedRead and directly bring it into a frame or something. That might work.

    -d

  8. breger
    Member
    Posted 10 years ago #

    Thanks, I'll give it a try.

  9. davidchait
    Member
    Posted 10 years ago #

    no problem. fyi, if you just change the extension from .htm to .php, so long as php is active it should grab index.php (now that index.htm is no longer there). well, if things on your server are set up 'properly'. then you can add all the php tricks you want to your homepage, without a complete overhaul, or nasty hacks.

    -d

  10. maccarrp
    Member
    Posted 9 years ago #


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

    Kafkaesqui got it right... just missing a single quote in the require line.

  11. RogerUsh
    Member
    Posted 9 years ago #

    Couldn't get this to work, am I entering it in correctly with my folder structure?

    http://imagebaker.com/posts/ (WP root directory)

    http://imagebaker.com/index.php (file I want to include WP functions)

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

    I also tried

    <?php
    define('WP_USE_THEMES', false);
    require('http://imagebaker.com/posts/wp-blog-header.php');
    ?>

    I also should mention that I am trying to get these functions to work with folderblog v2.02

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.