WordPress.org

Ready to get started?Download WordPress

Forums

Access Databse/Use WP functions from anywhere on Site. (5 posts)

  1. Fender963
    Member
    Posted 7 years ago #

    Can anyone walk me through, or tell me what code is needed so that I can use all of the WordPress functions and access my wordpress database from anywhere on my site?

    Thank you!

  2. whooami
    Member
    Posted 7 years ago #

    to start with you need this on any page you plan on plugging into your WP install:

    <?php require('path_to/wp-blog-header.php'); ?> <-- use the proper path

    from there, sql queries take the form of :

    $wpdb->get_results ...

  3. Fender963
    Member
    Posted 7 years ago #

    Can you tell me which parts of the header specifically are required. What happens if I want to pull from 2 different WordPress databases on the same page? Any help would be appreciated.

  4. moshu
    Member
    Posted 7 years ago #

    If you want to use "WP functions" on a site/file, as you stated in your title - you need exactly the code whooami posted. Not parts of it.

    You cannot pull data from 2 databases with this method.

  5. Fender963
    Member
    Posted 7 years ago #

    If I install 2 instances of WordPress on my site then but within the same database (and just with different prefixes i.e wp_ and articles_) can I use this method and then somehow just specify which prefix to pull from?

    - Kyle

Topic Closed

This topic has been closed to new replies.

About this Topic