+ Reply to Thread
Results 1 to 9 of 9

Thread: List Pages on another WP or a non-WordPress site

  1. #1
    JLeuze's Avatar
    JLeuze is offline Here For The Peanuts
    Join Date
    Jan 2009
    Location
    Minnesota
    Posts
    125

    Default List Pages on another WP or a non-WordPress site

    I've been doing some research on this and I'm stumped. Does anyone have a clever way to list the pages from one WordPress install on another install, or say on a static site?

    It seems like it would be a simple matter to talk directly to the database with PHP instead of going through WordPress. But I haven't been able to find any working examples and my PHP isn't so hot that I would attempt it from scratch.

    Am I mistaken, is this harder than I think?
    "The future is already here—it's just not evenly distributed." - Gibson

  2. #2
    Otto's Avatar
    Otto is offline Trac Master
    Join Date
    Apr 2009
    Location
    Memphis, TN
    Posts
    770

    Default

    What "pages" are you wanting to list, exactly?

  3. #3
    JLeuze's Avatar
    JLeuze is offline Here For The Peanuts
    Join Date
    Jan 2009
    Location
    Minnesota
    Posts
    125

    Default

    I should have clarified that better. I want to list WordPress Pages (with a capital P ) on a different install of WordPress, or possibly a non-WordPress static HTML page.

    So I guess I'm basically looking for the functionality of "wp_list_pages" as straight up PHP rather than a template tag so that it can be used outside of WordPress?

    I know people have had this problem trying to add dynamic navigation to bbPress from WordPress. I thought maybe I'd find some helpful info on the bbPress forums, but I couldn't find many solutions.

    This post seemed promising, but it looks like it depended on some bbPress functionality, I'm looking for a less platform specific solution.
    "The future is already here—it's just not evenly distributed." - Gibson

  4. #4
    Ryan's Avatar
    Ryan is offline WPTavern Forum Moderator
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,418

    Default

    wp_list_pages() is straight up PHP. However I think I know what you mean.

    If the other site is on the same hosting space then all you need to do is to call wp-load.php and then you can use any of the basic WP functions such as wp_list_pages().

    If it's on a seperate server, then there are bazillions of ways to do it. The simplest would be to create a file including wp-load.php and then declaring wp_list_pages() in it or perhaps achieve the same effect using your theme. Then have your other non-WordPress page check that, store the result in it's database (or similar) and just update it at set intervals. You could also read that data in on each page load but that will tend to load a little slow and it will break if the WordPress installation doesn't happen to connect with your other site.


    There are multiple ways of doing this. The simplest I think would be to add a

  5. #5
    JLeuze's Avatar
    JLeuze is offline Here For The Peanuts
    Join Date
    Jan 2009
    Location
    Minnesota
    Posts
    125

    Default

    Thanks for the leads Ryan, I didn't realize there was a way to run WP functions outside of WordPress. I'll check out wp-load.php.

    Yes, everything is on the same server and sharing a database too.
    "The future is already here—it's just not evenly distributed." - Gibson

  6. #6
    Ryan's Avatar
    Ryan is offline WPTavern Forum Moderator
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,418

    Default

    You can also use wp-blog-header.php which loads up a bunch of template related stuff too. But for most jobs wp-load.php seems to do the trick just nicely. In theory they're loading a significant proportion of WordPress each time they're fired, but in practice I haven't seen any significant change in performance after including either of them in my external apps.

    The only glitch I've experienced was in trying to use wp-load.php inside SMF. There seems to be a clash somewhere between the WordPress code and the SMF code and no one I've asked seems to know a work around for it :(

  7. #7
    JLeuze's Avatar
    JLeuze is offline Here For The Peanuts
    Join Date
    Jan 2009
    Location
    Minnesota
    Posts
    125

    Default

    Loading the wp-load.php file seems to be a pretty handy way of using WordPress content on static pages.

    I did some searching on how to use wp-load.php outside of WordPress and I found a great post on WPengineer.com that was really helpful.

    I didn't have any problem listing the Pages of a WordPress install in a non-WordPress PHP file.

    That could be handy right there for other projects. But for what I'm working on right now I need to load the Page navigation from one WordPress install into another WordPress install.

    I tried including wp-load.php file from the other install, but that didn't work at all. Which makes sense, since I'd be trying to include the wp-load.php file from two different installs, which seems like a good way to have the whole mess blow up in your face!

    Anyone else have any ideas for accessing this content from a WordPress database without using WordPress functions? I've been digging through lots of blogs looking for an answer, it seems to me like at some point someone must have written some PHP for this needing dynamic navigation from WordPress included in another platform.
    "The future is already here—it's just not evenly distributed." - Gibson

  8. #8
    wpmuguru is offline Here For The Peanuts
    Join Date
    Sep 2009
    Posts
    128

    Default

    You could make a page template that only outputs the output from wp_list_pages and use the template on a new source blog page (ex. hidden-list-pages). Then on the target blog or site use a wp_http or file_get_contents to retrieve the list. You would want to cache it though, so that it doesn't run on every page load.

  9. #9
    JLeuze's Avatar
    JLeuze is offline Here For The Peanuts
    Join Date
    Jan 2009
    Location
    Minnesota
    Posts
    125

    Default

    That's a sneaky idea, I'll have to check that out. Thanks guru!
    "The future is already here—it's just not evenly distributed." - Gibson

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts