WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a php file in my server (say www.example.com/up/up.php). If i access that file through the url, my site says no page found. but i want to call that php file using url parameter. I want to call that file to a download file using url access( say www.example.com/up/up.php?f=207). can someone help me how to do this. as usual i searched fr few days for my problem and came here when i totally cornered.

my up.php contains the following code

<?php /* Template Name: Upload */ ?>

  $app_id = "12345678901234567890";
  $app_secret = "12345678901234567890";
  $post_login_url = "www.mysite.com";
  $album_id = "7777";
  $photo_url = "URL";
  $photo_caption = "cool pics";

  $code = $_REQUEST["code"];

  //Obtain the access_token with publish_stream permission 
  if (!$code){ 
    $dialog_url= "http://www.facebook.com/dialog/oauth?"
      . "client_id=" .  $app_id
      . "&redirect_uri=" . urlencode( $post_login_url)
      .  "&scope=publish_stream";
    echo("<script>top.location.href='" . $dialog_url
      . "'</script>");
  } else {
      . "client_id=" . $app_id
      . "&client_secret=" . $app_secret
      . "&redirect_uri=" . urlencode( $post_login_url)
      . "&code=" . $code;
    $response = file_get_contents($token_url);
    $params = null;
    parse_str($response, $params);
    $access_token = $params['access_token'];

    // POST to Graph API endpoint to upload photos
    $graph_url= "https://graph.facebook.com/" 
      . $album_id . "/photos?"
      . "url=" . urlencode($photo_url)
      . "&message=" . urlencode($photo_caption)
      . "&method=POST"
      . "&access_token=" .$access_token;

    echo '<html><body>';
    echo file_get_contents($graph_url);
    echo '</body></html>';

I should pass a value to the url by using link

share|improve this question
You should be able to do it, just provide the full path to the file when you call it. – Jared Jan 22 '12 at 18:05
@Jared I gave the full url but it ends up with no page found error....should i add any codes to function.php about this external file?? – Felix Jan 22 '12 at 18:23
Well where are you placing the file, in your active theme's folder? – Jared Jan 22 '12 at 18:25
@Jared I placed it in my serever. www.mysite.com/up/up.php – Felix Jan 22 '12 at 18:27
Well I think it would work the same way even if you had the .php extension. I think it may be a conflict with your rewrite rules possibly, because I've never had a problem accessing a PHP file inside WP with the path to the file. – Jared Jan 22 '12 at 20:34
up vote 2 down vote accepted

What you can do is this:

Put up.php in your active theme's folder, and put this line at the top of your up.php file:

<?php /* Template Name: Up */ ?>

Create a page called Up in your WordPress Dashboard, then on the right side of the edit page screen, set the Template to 'Up'.

Depending on what you are doing with this file, you may need to add more code to make it completely secure, but this should at least solve the problem of you being able to access/use that file.

Read the relevant WordPress Codex page for more information:


share|improve this answer
gonna try it rite away :) – Felix Jan 22 '12 at 18:34
@Felix Let me know if it works! – Jared Jan 22 '12 at 18:40
i can acces the php page now but the code is not working. I used that code in my theme file (single.php) and it worked. but its not working now. should i add any extra code for that??? BTW the php file contain <?php /* Template Name: Up */ ?> <?php code lines ?> – Felix Jan 22 '12 at 18:44
@Felix I would need to see the entire up.php file in order to see where the problem is. Can you update your question with it? – Jared Jan 22 '12 at 18:49
@Felix By the way, you would then access the file using the page URL and not the URL to the PHP file. For example, if your page slug was up, you would use it like this: http://yoursite.com/up?f=207 – Jared Jan 22 '12 at 18:52

I have Found a way which I use regularly to add my own created PHP to a PHP PAGE or post through the use of Short Codes. Now Create a PHP page named example.php in your theme root directory. write something like:

echo "Hi! I am a PHP File in Wordpress template Folder!"

Now add the following code to your functions.php

function exampleFormInclude()
include( 'example.php' );
function exampleapp_func() {



$output = ob_get_contents();;

return $output;
add_shortcode( 'exampleapp', 'exampleapp_func' );  

Now add shortcode [exampleapp] in your page or post.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.