Support » Themes and Templates » Adding pages to WP Template

Adding pages to WP Template

  • I’d like to add another page inside the template, specifically one with a form and processing for a “email this to a friend” type link on each entry. I can handle the php etc for that, I’, just trying to figure out how to have my own php file that can use the wp get_header functions etc, whether i need to make wordpress call it, or whether i can emulate this myself, just some way to pull data from wordpress and use the right theme automatically. I was just going to write my own mysql queries, but that seemed rather redundant when wp can obviously already handle that.

    So to summarize, I’d like to include my own page inside of the wp system, to use wp functions on it, from the template directory. Thanks in advance…

Viewing 15 replies - 1 through 15 (of 18 total)
  • First, get familiar with the terminology, it will be easier to ask the right question (and get the right answer). Template is a php file inside of a Theme. All the files in a theme (or almost all:) are considered “templates”. You can add templates, especially Page templates in unlimited number and you can put all kind of code into them.
    Codex! – http://codex.wordpress.org/Main_Page
    and all the linked pages.

    hmm… I’ll try again then.

    Inside my website/wp-content/themes/mytheme directory, I’d like to place an additional php file that can use wordpress functions like get_header etc. Once I get that, I can do the rest of what I want to do, but what I don’t understand how to do is how to either get wordpress to load this file or how do get the file to load the right parts of wordpress…

    Once you develop the template, and drop it in your theme folder, go to write page in your admin area, and choose the template of your choice.

    Depending on the theme, you may have a page template default already there, but you can create as many page templates or alter other templates as you desire.

    Greyhat, did you read all that stuff I’ve linked? I mean before “trying again”. I am afraid you didn’t have the chance. You’ll find all the asnwers there.

    I don’t want to make a WordPress “Page” thats listed on the side menu. This is to be an intermediate page for an internal function of the site, not an About page or something…

    As an aside… I really really like a lot of WordPress, especially the admin area… but half the time when I try to make more involved customizations I feel like I’m trying to do the impossible and would be better off writing my own cms…

    Also, I did read the links, but found nothing explaining this…

    Nothing HAS to be listed in your sidebar. You wouldn’t need a link to it, per se. However

    I’d like to add another page inside the template, specifically one with a form and processing for a “email this to a friend” type link on each entry

    was how you started this thread. Therefore, we have nothing else to go on. It sounds like you might be better served creating a plugin that does the funtion you want, and being able to call the function within an existing template, such as your index.php

    Apparently I’m still messing up on terminology or something.

    I want… a php file that can use wordpress functions, located in wp-content/themes/mytheme/.

    I don’t want to use the wordpress page maker to add a page to the database and site, or anything else like that, just a php file that can get things out of wordpress.

    Then you have been directed to the correct area of the codex. If it is in themes/mytheme, it is a template. Period. Be it a page template, or your index.php file, all the files in that directory are called templates. So looking at the codex in those areas is where you want to be.
    All the WP specific “commands” that can be used in a template, or as you are saying “get things out of WordPress”.

    I guess I’ll just do this myself… apparently it *was* too much to ask.

    No, what was too much to ask was for you to clearly explain your question, if the information provided didn’t genuinely answer your question. You asked what you needed to do to create a php file in your themes/mytheme directory. You were directed to the correct area of the codex to explain the process.
    If you are asking something else, then by all means, clarify your position.

    I don’t know how I can state it any clearer. I want to run my own php code, inside of a php file that has the header and footer and can use the wordpress functions, like the other php files in the wp-content/themes/mytheme directory. I either need to know how to access that by having wordpress load that instead of some other file in the mytheme directory, or how to fake it by including something from wordpress.

    Just so we are getting on the same page
    that link is to the default page template. You could take that, and add your own php, or you can use a plugin, such as PHP Exec
    Which will allow you to use a page template, and put the code directly into the page using the write page feature in the admin area.
    The other option that was mentioned, was to create a plugin, which is also a php file, that would allow you to call that function within a template.

    I don’t want to modify pages.php, I want to put a whole new file in there… that seems to be the problem.

    I give up. You are not following, so either someone else will find a way to explain to you that pages.php can be anything you want it to be, and can be called anything you want. It can have <?php get_header(); ?> at the top, and <?php get_footer(); ?> at the bottom, with your code and any template tags you want to include.
    You can also use the plugin I showed, which would allow you to have a quicktag <phpcode>, and insert your php code via the write page.

    just include wp-blog-header.php and you have access to all WP functions

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Adding pages to WP Template’ is closed to new replies.