Forums

Page template question (24 posts)

  1. Hughlicious
    Member
    Posted 7 years ago #

    Ok, first of all, please be gentle with me, I'm so clueless, I just don't get a thing right now. I've been reading up and down the WordPress Codex page, but maybe I'm just too stupid.
    So I tried to create a page using wordpress, and that is all well, if I liked the template it comes with, and I have no idea how to change it. In the dropdown box under the text field, where it says add custom field, all I can choose is _wp_page_template. Don't know where this _wp_page_template has it's coding stored.
    The page I tried to create is here and there's some stuff I'd like to get rid of.
    <div id="c-col">
    <div id="banner">
    <h1>Welcome To Silent Dreams!</h1></div>

    <div id="content">
    <!-- end header -->

    <div class="title">Saturday ::: February 19, 2005 ::: 09:25 am ::: Adoptions</div>
    <div class="post">
    <div class="storycontent">
    <!-- center column -->

    and
    <div class="divider">�</div>
    <table width="100%" border="0"><tr>
    <td align="right">

    </td></tr>
    </table>

    <!--
    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
    <rdf:Description rdf:about="http://www.silent-dreams.org/?page_id=136"
    dc:identifier="http://www.silent-dreams.org/?page_id=136"
    dc:title="Adoptions"
    trackback:ping="http://www.silent-dreams.org/wp-trackback.php?p=136" />
    </rdf:RDF> -->

    </div>

    <h2 id="comments">No Comments
    </h2>

    No comments yet.

    <a href="http://www.silent-dreams.org/wp-commentsrss2.php?p=136">RSS feed for comments on this post.</a>

    Sorry, the comment form is closed at this time.

    <!-- begin footer -->
    </div>

    Is anyone able to help me with this?

    And in addition to that, did I misunderstand the permalink thing? Shouldn't the page mentioned above be accessible through http://www.silent-dreams.org/adoptions/ ? 'Cause that's not working...

  2. Hughlicious
    Member
    Posted 7 years ago #

    Anyone? Please?

  3. Hughlicious
    Member
    Posted 7 years ago #

    Trying to bump this one last time, but I guess noone can/wants to help me.

  4. Hughlicious
    Member
    Posted 7 years ago #

    Bumping this again, since I still have the problem and am hoping that with spring having finally started, people might be a bit more helpful. ;)

  5. Minna
    Member
    Posted 7 years ago #

    Does the theme you are using have a Page template?

    You can't really do anything with _wp_page_template. If you had templates to choose from, they'd appear in the Page Template menu.

    As for the permalink, have you updated .htaccess or is WP able to update it? (the permissions should be 666, that is read-write for all (or just you and other, that is 646))

  6. Root
    Member
    Posted 7 years ago #

    Hughlicious - the reason you have not had an answer is that because we are newly at 1.5 this q would be fairly considered to be at the high end of web dev. As I understand it you need to create a template first. Then as you create the page you can associate the template in the drop down.

  7. Hughlicious
    Member
    Posted 7 years ago #

    I tried with the default theme. It comes with page.php, that's what is needed right? It still doesn't display in the drop down though. :(
    .htaccess? I have an empty one in my main folder, is that what you mean?
    Sorry, I'm really quite clueless about this all. :/

  8. Minna
    Member
    Posted 7 years ago #

    For Permalinks to work, you need to allow WP write in your .htaccess (it should be in the blog's root/main folder where you have it). You don't have permalinks enabled at the moment (because your posts are referred to as "?post=x") so unless you *insist* on having the tidy page links, you don't have to turn permalinks on at all.

    page.php (the Page template) is used, if found, when pages are viewed. You don't *need* it but it's easy to customise pages with it as often you don't want comments and things on the pages.

    It's not a page template as such, just similar to post template, archive template, main template. It's used in the correct context.

    Page templates have a
    <?php
    /*
    Template Name: My page
    */
    ?>

    declaration at the beginning and *they* show up in the dropdown.
    If you want to remove those things you mentioned from ALL your pages (current and upcoming), it's easiest to make a page template: you create a page.php file and put it on your theme's folder.

    I know this reply is getting long, but here's a cleaned up version of my page template, in case it helps at all. This you would save as page.php and put in the correct theme folder:
    <?php get_header(); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="post">
    <h3 class="storytitle" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    <div class="meta">
    <?php edit_post_link(); ?>
    </div>
    <div class="storycontent">
    <?php the_content(); ?>
    </div>
    </div> <!-- post -->
    // this is to show how I enable comments only
    // on my feedback page
    <?php if (is_page('feedback')) { ?>
    <?php comments_template(); ?>
    <?php } ?>
    <?php endwhile; else: ?>
    <?php _e('Sorry, page not found.'); ?>
    <?php endif; ?>
    <?php get_footer(); ?>

    Maybe with the help of that you can build up the page your your dreams.... :P I'll be happy to help with the rest of the "tweaking". (as some of the things you want "deleted" aren't controlled with page.php)

  9. Root
    Member
    Posted 7 years ago #

    Minna am I right in saying that templates other than the pre installed like page.php need to be plugins ? Or can we name something like your template above as anything we like (barring WP names of course) and it will work ?

  10. Jinsan
    Member
    Posted 7 years ago #

    The template can be named anything you want - for example I constructed a template called gordon.php but use it for the purposes of your about page - what you call your template I don't think really matters, but for reasons of organisation and understanding, it's usually a good idea to name them what you will use them for. YOu can then use that same template for several different pages.

    For example, say you create an about page and create a template for it, you name that page about bob - you can then decide to add another page called about sue using that same template. Or use it for something completely different.

  11. Minna
    Member
    Posted 7 years ago #

    Root, I'm not sure how to interpret plugin in that context, but as to the 2nd quesion: yes, you could make a file anythingyoulike.php, put it in your theme folder, and it would be available to be used on pages. The archives (where you see month and category) in default theme (I know you don't use it.... :P ) are actually made as a "user-made page template".

    You'd need to include that little "declaration" as the first thing of the template and then it would show up in the dropdown

    I hope I'm making some sense...

  12. Jinsan
    Member
    Posted 7 years ago #

    and just to add page.php is just the name of a template with a theme, some themes I found to even come with templates so you just make your own or copy and paste an existing template - I've found them to be really flexible, particularly if using the same template for several things.

  13. Root
    Member
    Posted 7 years ago #

    And this will work even if your new template new.php is not associated with a page - or can you call it from another template using get_new ()

  14. Jinsan
    Member
    Posted 7 years ago #

    I don't think get new would work, but you could use

    <?php load_template( TEMPLATEPATH . '/new.php'); ?>

    instead which would work, and place that in the top of whatever file you want to call it to. Or create the file and then create a page and set it to use that template as the page.

  15. Root
    Member
    Posted 7 years ago #

    Ah. That was what I needed. Thanks.

  16. moshu
    Member
    Posted 7 years ago #

    You can create as many Page templates as you want, and they all will show up in the dropdown options on the Write Page panel at Page Option > Page Templates. (The one named Default Template = your page.php in your theme!)
    For filenames you can use almost anything (anything.php :) except these 2 lists - those files having a special meaning in WP.

    In Dark Maple I wanted to have a page to display the searchform, so I created a file, named searchpage.php (since search.php is reserved for the search results template!), put on the top:
    <?php
    /*
    Template Name: Search
    */
    ?>

    though I could write here anything instead of "Search"... and it has the usual get header, footer, sidebar etc. calls, plus in the content div this:
    <?php include (TEMPLATEPATH . '/searchform.php'); ?>
    When I was done with the template + uploaded, I went to create a new Page, did NOT write anything in it, just selected as template "Search" from the options given, clicked... and voila! Then I checked its ID in the Manage Pages section and hardcoded the page_id link in the horizontal menu.

    I hope it makes sense :)

  17. Root
    Member
    Posted 7 years ago #

    It is the php include that is eliusive to php beginners. Thanks. Even I can understand that. :)

  18. Hughlicious
    Member
    Posted 7 years ago #

    OK, the "Page Option > Page Template" part confused me....I don't actually have that?
    I was always looking at the new custom field part on the page.
    Here is what my page looks like.

  19. Root
    Member
    Posted 7 years ago #

    You are on WP 1.5 ?

  20. moshu
    Member
    Posted 7 years ago #

    That's strange... Above the Page slug there should be a Page Template drop-down menu option for templates.

  21. Hughlicious
    Member
    Posted 7 years ago #

    Yes, I'm on 1.5
    How weird! But at least that tells me I'm not all that stupid. ;)

    I will redownload the script as soon as I'm home (at work right now) and re-upload the page-new.php page. Maybe that helps.

  22. Hughlicious
    Member
    Posted 7 years ago #

    OK, I couldn't wait and downloaded it again just now and re-uploaded it. That didn't change a thing though...

  23. Hughlicious
    Member
    Posted 7 years ago #

    So almost everything is figured out now. Thanks so much Minna for the page template!
    I still can't figure out the link thing though. Is there anything else I have to do to turn on the permalinks besides making the .htaccess file accessible?
    Is it supposed to be empty btw?

    Nevermind! I think I understand the permalinks thing now. :)

  24. Michael Adams (mdawaffe)
    Member
    Posted 7 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.