Adding pages to WP Template (19 posts)

  1. greyhat
    Posted 10 years ago #

    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...

  2. moshu
    Posted 10 years ago #

    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.

  3. greyhat
    Posted 10 years ago #

    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...

  4. Michael Bishop

    Posted 10 years ago #

    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.

  5. moshu
    Posted 10 years ago #

    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.

  6. greyhat
    Posted 10 years ago #

    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...

  7. Michael Bishop

    Posted 10 years ago #

    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

  8. greyhat
    Posted 10 years ago #

    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.

  9. Michael Bishop

    Posted 10 years ago #

    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".

  10. greyhat
    Posted 10 years ago #

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

  11. Michael Bishop

    Posted 10 years ago #

    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.

  12. greyhat
    Posted 10 years ago #

    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.

  13. Michael Bishop

    Posted 10 years ago #

    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.

  14. greyhat
    Posted 10 years ago #

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

  15. Michael Bishop

    Posted 10 years ago #

    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.

  16. Joshua Sigar
    Posted 10 years ago #

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

  17. greyhat
    Posted 10 years ago #

    Thanks alpha, thats what I was asking for! =)

  18. bugsmi0
    Posted 8 years ago #

    I think sometimes advanced users can take the "did you read the documenation" too far, there's only so much reading one can do, how many hundreds of pages must one read before they find the answer ;-) I think its great to do some searching before we post but for how long must we search until we are worthy of posting ? I think some compassion is in order for the newbies, personally I find the links suggested here not clearly explained for a newbie maybe for an advanced programmer. I can't make heads or tales out of the page template instructions. Cut the newbies some slack, you were one once ;-)

  19. DickMo777
    Posted 8 years ago #

    As a blog newbie who is trying hard to learn, I am sympathetic to the problems of understanding both Codex and sometimes even support writings. But, on the other hand, it is unreasonable to expect the volunteer support folks to start from scratch to provide all the necessary background information in response to each question.

    May I suggest that someone write a set of sequential documents in Codex (or a separate text) to educate the newbie? Yes, there are such documents, but they don't do the job and they don't fit together as a single textbook. Terms are not always explained, and referring to the glossary is clumsy and doesn't always answer the issues arising from the Codex document because they are written separately.

    Topics of the "textbook" might include:

    What is a style sheet, a template, a page, a post, etc. (Yes, with research you can find Codex info on each of these, but they don't fit together nicely as a text.)

    Where (as a URL, perhaps) can you find the various files, posts, parameters, templates, etc. that WP uses, and how can you access them? What is the structure of MySQL, and should I ever get into it directly? If so, how?

    What's the proper method for making changes of various kinds? When should you do it offline and upload it, or do it from within Admin? When do you need to make changes directly in html, and how? If you instead edit the displayed text in Admin/Manage/Page, how can you control things that don't show up in that display? (Do I even know the right questions to ask?)

    And much more.

    Before publishing the text, several complete newbies should review it and mark everything they don't understand. At that point I predict it will be mostly red ink. So start over again and get it reviewed again. And again. Until a total newbie can read the textbook and create a blog and know what he or she is doing besides just blindly following a cookbook recipe written in a strange language by fifty authors who don't necessarily communicate with each other.

    Can that be done without paid writers? I don't know.

Topic Closed

This topic has been closed to new replies.

About this Topic