1

I wish to add a custom page to wordpress, not in the usual sort of way. This page has my own custom script and functions and to develop a plugin is beyond my means so I was wondering if this is possible:

Suppose I were to build it on the existing page.php script in my there folder, my script looks something like this:

<?php get_header(); ?>
                        <div id="left-area" class="clearfix">
                                <?php 

                                //My script would go here 

                                ?>

                                <div class="comments">
                                        <?php comments_template('',true); ?>
                                </div><!-- end of comments div -->             

                        </div><!-- end of left-area -->
                        <!-- LEFT AREA ENDS HERE -->

    <?php get_sidebar(); ?>

<?php get_footer(); ?>

Is this even possible? I tried and got a page not found error. And if so, how do I call this script assuming WP is installed in the root directory? Example: www.mysite.com/myscript

1 Answer 1

1

Absolutely. Duplicate page.php. Rename it to template_mine.php. Open to edit, and before the get_header tag, add:

<?php 
//
// Template Name: My Custom template (choose something more descriptive, like contact page)
// 
?>

Go to Wordpress dashboard for pages, create a new page with your title, and in the Page attributes on the right hand side, under templates, select your template name, update, and you are all set.

Reference: http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks anuragbh! But how do I call it, and what if I need to gather POST/ GET values if this page is displayed as a result of a Form that is filled in. For example, a form filled on the home page would display results on this page based on the data entered.
You can use $_GET and $_POST to receive those variables as usual. Basically these lines are added on top of your php template file as comments. Start your php code below these lines. So you might have: // // Template Name: Contact Page // $name = $_POST['name']; get_Header(); ?>
I didn't understand what you meant by how you would call it. Did you create the page in Wordpress dashboard and assign it your custom template?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.