SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist JordashTalon's Avatar
    Join Date
    Dec 2008
    Posts
    505
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Inserting PHP into Wordpress

    Hello,

    I was successfully able to insert PHP into Wordpress using Exec-PHP

    http://bluesome.net/post/2005/08/18/50/#execute_php

    However I use an include to include my external PHP file

    inclue('phpfile.php');

    The PHP file tries to get the Server URL using:

    $url=$_SERVER["REQUEST_URI"];

    however $_SERVER["REQUEST_URL"]; returns phpfile.php instead of the http://domain.com/webaddress

    I'm trying to get the second, it works if I insert the PHP directly into the Wordpress content, but I can't do it with an Include, any ideas? How do I make an include as if I were directly pasting the PHP code into the post?

    Thanks

  2. #2
    SitePoint Wizard Nikolas's Avatar
    Join Date
    Feb 2005
    Location
    Greece
    Posts
    1,221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try to include with dirname. Example :

    PHP Code:
    include dirname(__FILE__) . '/file.php'

  3. #3
    SitePoint Evangelist JordashTalon's Avatar
    Join Date
    Dec 2008
    Posts
    505
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That helped I found out that if you want to do what I'm trying to do you should include without a direct link to the PHP file
    e.g.

    WRONG: http://domain.com/PHP/PHPfile.php
    RIGHT: PHP/PHPfile.php

    so

    include("PHP/PHPfile.php")

    works,

    Thanks it's working now


Bookmarks

Posting Permissions

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