WordPress.org

Ready to get started?Download WordPress

Forums

Problem accesing WordPress within my PHP app (1 post)

  1. juanjico
    Member
    Posted 2 years ago #

    Hi!

    I'm accessing the WordPress API from within my PHP code just including the wp-blog-header.php and using get_posts().

    This is working ok when my PHP code is at the same level than the WP directory. For example:

    /index.php
    /blog/[..wp files..]

    At index.php, I have:

    require('blog/wp-blog-header.php');
    $post = get_posts(...);

    and is working pretty well.

    BUT, when I try to do the same with the code inside a directory, for example:

    /blog/[..wp files..]
    /folder/index.php

    and at folder/index.php I have:

    require('../blog/wp-blog-header.php');
    $post = get_posts(...);

    this always makes my app to redirect to the WP installation (wp-admin/install.php) and doesn't work.

    Any idea ? Can the API be used from within a directory ?

    The blog is configured correctly and is working ok by itself.

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags