The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

WordPress API? (6 posts)

  1. Deane
    Posted 11 years ago #

    How easy is it to abandon WordPress templates completely?

    I have a site into which I want to integrate WordPress, but it would need to live in and around amongst much other code. WordPress would power small pieces on certain pages, but it would never be the sole focal point of an entire page.

    I've done a little work with this in a plugin:

    $lastFivePosts = get_posts('');
    foreach ($lastFivePosts as $post)
    //Stuff here

    But the whole plugin thing would get a little unwieldly. Is there an existing PHP API (not the plugin API) that would let you access WordPress posts and such from outside the system? Obviously, the code above works solely because its runs in the context of WordPress, with all the include files and such that it entails.

    I know I could do raw SQL -- and I will without other options -- but I was hoping someone else had done something similar.


  2. vkaryl
    Posted 11 years ago #

    Check the Codex for info about The_Loop on non-WP pages....

  3. XeroCool
    Posted 11 years ago #

  4. Denis de Bernardy
    Posted 11 years ago #

    Funny, I'm taking the opposite approach. WordPress' plugin API is not perfect but it makes it the most powerful CMS platform I've tried so far. If I were you I'd give it another shot.

    First off, grab the following for inspiration:


    Then, get a plugin like php exec:


    And that's it. You get:

    - A fully functional CMS that lets you easily create and manage any number of pages, with any number of page templates
    - A way to insert custom code (e.g. a forum, an image gallery) and features anywhere you want in your pages

  5. Denis de Bernardy
    Posted 11 years ago #

    Also, you might want to check the doc for $wpdb, to fetch custom code listings.

  6. davidchait
    Posted 11 years ago #

    wordpress templates give you default navigation and content display. if you want to do something differently, you certainly can. I think the key starting file to look at is wp-blog-header.php, as that really starts off all processing, etc. You can also direct-include wp-config to start things off, though you now have to manually call a few more things (that imho should have been in config but are in blog-header).

    really depends on what/how you are looking to integrate, and what the 'rest of the site' is that isn't using WP stuff... i.e., why WP at all?


Topic Closed

This topic has been closed to new replies.

About this Topic