WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] External PHP-file gain access to native functions? (2 posts)

  1. 2biazdk
    Member
    Posted 1 year ago #

    Hi guys,

    I'm trying to write a plugin here, and I'm going to need jQuery to make an AJAX-call to a PHP-file (which fetches all posts as JSON).

    But how can that external PHP-file gain access to native WordPress-functions such as get_posts()?

    Right now the PHP-file just contains:

    <?php
    // ...
    ?>

    But I guess I need to include the native functions somehow?

    Hope you can help me, as I'm currently stuck.

    Thanks in advance!

    Kind regards,
    Tobias

  2. 2biazdk
    Member
    Posted 1 year ago #

    Woah, that was easy...

    I just included:

    require_once('../../../wp-blog-header.php');

    in the top of the new PHP-file, and now I could use all WP-functions.

Topic Closed

This topic has been closed to new replies.

About this Topic