Title: make a new PHP file and paste code into it?
Last modified: August 19, 2016

---

# make a new PHP file and paste code into it?

 *  [photog313](https://wordpress.org/support/users/photog313/)
 * (@photog313)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/make-a-new-php-file-and-paste-code-into-it/)
 * I am trying to paste the code below and can’t seem to find clear info on how 
   to make a PHP file? What I did so far is create a PHP folder within my Hosts 
   file manager at wp-content/plug-ins/my php folder. But once the folder was created,
   I had nowhere to paste the code?
 * I am really new to wordpress and am starting from scratch with coding. Any help
   would be much appreciated. Here is the code:
 * <?php
    /* Plugin Name: Custom Post Templates Plugin URI: [http://boren.nu/](http://boren.nu/)
   Description: Load custom single post templates. Author: Ryan Boren Version: 0.9
   Author URI: [http://boren.nu/](http://boren.nu/) */
 * function cpt_custom_post_template($template) {
    global $wp_query;
 * $post = $wp_query->post;
    $id = $post->ID;
 * // If a template exists for this post ID, load it.
    if ( file_exists(TEMPLATEPATH.“/
   single-{$id}.php”) ) return TEMPLATEPATH . “/single-{$id}.php”;
 * // Add custom checks here. For example, give posts different templates
    // depending
   on what categories they are in. if ( in_category(‘1’) && file_exists(TEMPLATEPATH.‘/
   single-cat-1.php’) ) return TEMPLATEPATH . ‘/single-cat-1.php’;
 * return $template;
    }
 * add_filter(‘single_template’, ‘cpt_custom_post_template’);
    ?>

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Bas Schuiling](https://wordpress.org/support/users/basszje/)
 * (@basszje)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/make-a-new-php-file-and-paste-code-into-it/#post-1300416)
 * I think you’d better pick up a book about PHP if you want to learn to do something
   with it.
 * To answer your question, PHP-files are nothing more than textfiles residing on
   the server and being interpreted by apache/php . Copy-pasting plugins ( why would
   you want that in the first place? ) has nothing to do with that.
 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/make-a-new-php-file-and-paste-code-into-it/#post-1300419)
 * I think what you want to do is use Notepad, or something like it, to paste the
   php code. Then save it to a file on your local drive and use the file manager
   to upload it to your host directory.
 *  Thread Starter [photog313](https://wordpress.org/support/users/photog313/)
 * (@photog313)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/make-a-new-php-file-and-paste-code-into-it/#post-1300420)
 * I added a wordpress photo template ( which was simple ) by a designer who suggested
   using this technique to load this code. Apparently it allows you to assign a 
   custom template to any post ID which means you can make one specific page look
   completely different than all of the others. Maybe I am getting ahead of my self,
   but I’m even having a hard time loading a twitter plugin for my blog, which is
   bizarre since loading the template was practically effortless.
 * Thanks for the reply!
 *  Thread Starter [photog313](https://wordpress.org/support/users/photog313/)
 * (@photog313)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/make-a-new-php-file-and-paste-code-into-it/#post-1300422)
 * @ vtxyzzy; that makes sense to me. i’ll give it a go. Thanks.
 *  Thread Starter [photog313](https://wordpress.org/support/users/photog313/)
 * (@photog313)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/make-a-new-php-file-and-paste-code-into-it/#post-1300427)
 * Okay, I was able to load the code into my File Manager,but when selected, it 
   does not allow me to Extract the file in order to Activate the plugin?
 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/make-a-new-php-file-and-paste-code-into-it/#post-1300610)
 * Sorry, I don’t know why you need to ‘Extract’. Just save the code in a file named‘
   cpt-custom-post-template.php’. Create a folder in plugins named ‘cpt-custom-post-
   template’ and copy the file into that folder. You should be good to go.
 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/make-a-new-php-file-and-paste-code-into-it/#post-1300617)
 * I would like to second what basszje said, though – get some good books, or do
   a lot of reading in the Codex.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘make a new PHP file and paste code into it?’ is closed to new replies.

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [new](https://wordpress.org/support/topic-tag/new/)
 * [paste](https://wordpress.org/support/topic-tag/paste/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 3 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [16 years, 6 months ago](https://wordpress.org/support/topic/make-a-new-php-file-and-paste-code-into-it/#post-1300617)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
