WordPress.org

Ready to get started?Download WordPress

Forums

How to add your own pages?? (25 posts)

  1. Belewien
    Member
    Posted 9 years ago #

    What kind of code do I have to add so my pages that I've made myself (not via wp's admin panel) show up? I've been using header.php & footer.php with my sites.. but now since upgrading to 1.5. none of my sites are showing correctly?

    I mean I have page called bio.php and it goes something like this:

    <?
    include('header.php');
    { ?>
    here is the content....
    <? }
    include('footer.php'); ?>

    but now I'm getting all weird errors.. please help!?!

  2. Belewien
    Member
    Posted 9 years ago #

    please, anybody? I'm really in trouble now :/

  3. Joshua Sigar
    Member
    Posted 9 years ago #

  4. paddyrs
    Member
    Posted 9 years ago #

    I know exactly what you mean Belewien - I can't figure out how to do it either! Alphaoide, I think doesn't want to use those sort of pages. (Not via wp's admin panel)..

    I want to do the same thing and I've tried using
    <?php get_header(); ?>
    <?php get_sidebar(); ?>
    for the first two lines and then adding my content and finishing with get footer.. and all it shows is:

    Fatal error: Call to undefined function: get_header() in /home/rbox/public_html/paddy/wp-content/themes/benevolence/about.php on line 1

    I think I have the same problem as Belewien even though I tried doing the header differently.

  5. Minna
    Member
    Posted 9 years ago #

    I believe adding a
    <?php
    require('./wp-blog-header.php');
    ?>

    at the very top of a page helps (it brings all the WP functions to your disposal)
    If the path is like that (./wp-blog-header.php) the files should be in your blog's root folder

    Somebody yell at me if I'm completely off the track :D

  6. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

    You need to make sure the code in wp-blog-header.php gets executed before at the very beginning of your page:

    <?php require('_path_to_/wp-blogheader.php'); ?>
    where _path_to_ is the path to that file.

    Why you want to do this when you can define custom Page Templates? Just curious.

  7. paddyrs
    Member
    Posted 9 years ago #

    Hmmm, I tried the one you gave me, and also <?php require('/paddy/wp-content/themes/benevolence/header.php'); ?> (my file is for some reason not wp-blogheader.php but header.php

    I want to do this instead of page templates because I dont want all that File Under, posted @ and RSS feed stuff... and I want to put HTML tables and stuff on the pages. Can you do that?

  8. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

    It really should be wp-blog-header.php. It's in the main directory of your WordPress install. (Perhaps /paddy/wp-blog-header.php)

    But yes, you can do anything you like in a custom Page Template. Include as few or as many WordPress functions as you want, as much or as little PHP as you want and whatever HTML strikes your fancy. See the examples on that link I gave you; the first is an example of a "dummy page", which may be what you're after.

  9. paddyrs
    Member
    Posted 9 years ago #

    OK! Great - thanks mdawaffe!

  10. Belewien
    Member
    Posted 9 years ago #

    But what if I've done my own header AND footer.. Do I have to include the stuff from my header to wp-blog-header.php or the other way around? And I'm also using footer.php how can I make that work? :/ I've got over 20 extra pages and I really wouldn't want them to go to waste... >_<

  11. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

    require wp-blog-header.php from your header file
    then include that header file in each of your pages:

    myheader.php:
    <?php require('_path_to_/wp-blogheader.php'); ?>

    mypage.php:
    <?php include('myheader.php'); ?>
    Stuff
    <?php include('myfooter.php'); ?>

    But I still think WordPress Pages and custom Page Templates will be a better solution in the long run for most of your extra pages.

  12. paddyrs
    Member
    Posted 9 years ago #

    I'm confused with adding my own pages...
    <?php
    /*
    Template Name: Photos
    */
    ?>
    Do I add that in my "Write Page" thing? I don't understand how it works...

  13. paddyrs
    Member
    Posted 9 years ago #

    http://rocketbox.org/paddy/?page_id=6

    Oh that page I basically want it to be blank to begin with.. so then I can add whatever I want..

  14. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

    No - put it at the very top of a new file. Call it photo-template.php, for example. Then put in whatever PHP and HTML code you want after that.

    Create a Page and select from the Page Template dropdown "Photos".

  15. Belewien
    Member
    Posted 9 years ago #

    Nope.. still doesn't work.. look this for example: http://frozen-rose.org/blog/me.php
    I only really want the blog thingie on my site with my other pages.. not the other fancy stuff. Maybe it's better to get that earlier version back... :/

  16. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

    It looks like the paths to your header and footer files are wrong.

    Broken Record: I truly believe that in the long run, Custom Page Templates (as referenced above) will be easier. The method you are using will work, though.

  17. Belewien
    Member
    Posted 9 years ago #

    I've put the headers & footers in the themes directory like it should be..
    so what path is right?
    <?php include('myheader.php'); ?> or <?php include('./myheader.php'); ?> or <?php include('path_to/myheader.php'); ?>... but I'm using 3 different themes and I want the visitors to be able to switch them. Am I trying something impossible?

  18. Belewien
    Member
    Posted 9 years ago #

    So nobody is using Wp 1.5 succesfully with other sites included (bio, gallery, links etc) than the blog itself? I know there's a way to do extra pages via WP's admincp but redoing 20+ sites it's gonna be just too much work.

  19. Kafkaesqui

    Posted 9 years ago #

    <?php include( TEMPLATEPATH . '/myheader.php'); ?>

    TEMPLATEPATH is a constant (PHP *permanent* variable) in WordPress that defines the current template (i.e. theme) directory. Is this what you're looking for?

  20. moshu
    Member
    Posted 9 years ago #

    A lot of people are succesfully usinf the Pages feature in WP 1.5. The only thing is you have to study a bit in the Codex how the templates and Pages work together.
    Do you want a different layout for every page of all your 20+ pages? or do you need only ONE page-template that will handle the layout of your pages?

  21. Belewien
    Member
    Posted 9 years ago #

    I have 2 (soon 3) different themes that I'm going to use, so that my visitors can switch the themes and choose the one they like best. I use to have my site skinned before so I just modified them to themes. I see the index page ok, where is my actual blog but I can't get the other sites I've made (not via admincp! there's info about me and so on) to show up properly. I'm using headers & footers in my themes, like I explained before. Now I only want to know how can I set the other sites that I've made to use the themes also, I only see white pages with the content in it (like --> http://frozen-rose.org/blog/me.php ).
    Is this code: <?php include( TEMPLATEPATH . '/myheader.php'); ?> going to able the theme switching also?
    I've tried using the "<?php require('_path_to_/wp-blogheader.php'); ?>" in my "header.php" file but I always get the same error message:
    "Warning: main(header.php): failed to open stream: No such file or directory in /home/frozenro/public_html/blog/me.php on line 1

    Warning: main(header.php): failed to open stream: No such file or directory in /home/frozenro/public_html/blog/me.php on line 1

    Warning: main(): Failed opening 'header.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/frozenro/public_html/blog/me.php on line 1"

    all my other 20+ sites I've made are in the root directory of WP, should I transfer to somewhere else? would that help?

  22. Belewien
    Member
    Posted 9 years ago #

    *going up* ... anybody?

  23. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

    Are you actually writing "_path_to_" (BAD), or are you replacing that with the actual path to that file (GOOD)?

  24. paddyrs
    Member
    Posted 9 years ago #

    Brilliant! Belewien, if you do what mdawaffe said (with the pages and themes and all that), you can have it howEVER you want. You can put the header, sidebar in or just have a completely blank page. Thanks mdawaffe. Worked well.. just gotta go customise!

  25. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

    No worries. I truly do think Page Templates make life a lot easier. It's easier to include headers/footers and other templates, plays nice with the rest of the WordPress theme system (and makes things easy to switch between themes, Belewien), is easier to update, is completely customizable, integrates with WordPress with zero effort, and is devoid of these funny path issues that seem to complicate people's lives.

    Glad you agree with me, paddyrs :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.