WordPress.org

Ready to get started?Download WordPress

Forums

Using Pages in 1.3 (15 posts)

  1. Maciej Ku? (maciekkus)
    Member
    Posted 9 years ago #

    Hello everybody.
    I'm new to WordPress, and started to learn to use WP 1.3 verison first. I installed WP 1.2.1 too, and noticed the difference (one of many), which are "Pages".
    As I think that feature allows me to add pages like "about me", "page containg rather static info", "contact form" etc. to whole wp-powered blog.
    But I couldn't find information how to link to that pages.
    Am I supposed to hard-code those links to wp template or index.php file?
    Or there is a possibilty to display list of those links in some more automatic way (eg. php code). I could then insert it to div tag for css-based menu.
    Sorry for possible mistakes in english
    Maciek Kus ibex.pl

  2. lstelie
    Member
    Posted 9 years ago #

    Hello
    in admin :
    1- you create a page
    2- you save it
    3- you go to "manage page" and then you have the usaual 3 links edit/view/delete
    The view link is the url of the page.
    The page system updates automatically the .htaccess file so you don'y need to manage that manually
    If you page is supposed to contain php code :
    1- you create the php file using the skeleton of the index.php file in your template and you add at the very beginning of the file
    <?php
    /* Template Name: NAME_OF_THE_PAGE

    2- you create a page but you don't fill the content, instead you choose your php file in the "template" menu
    The page system is a very powerfull feature of 1.3
    Hope this helps
    Luc

  3. khaled
    Member
    Posted 9 years ago #

    Now here's the 30 million dollar question. I want page that has a specific formatting to it. Say for example I want all the text to go in a column on the right and an image on the left.
    The thing is it's different from the main template, so I make a new php file like you said above etc.
    Now I want the text I write in the page edit section of the wp control panel to show up in my specially formatted php file.
    What code do I include in the php file I created that will call all the text I've written in the page in the wordpress control panel relating to that particular page?
    it's not
    <?php if (have_posts()) : ?>
    <?php the_content(); ?>
    <?php endif; ?>

    I've already tried that.

  4. Joshua Sigar
    Member
    Posted 9 years ago #

    How about

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="post">
    <div class="entry">
    <?php the_content(); ?>
    </div>
    </div>
    <?php endwhile; endif; ?>

  5. khaled
    Member
    Posted 9 years ago #

    d'oh. Thanks alphaoide :)

  6. Maciej Ku? (maciekkus)
    Member
    Posted 9 years ago #

    @all
    Thank you for help,
    I've got one more question:
    I want to make a navbar with links to my pages. But I want it to be automatically updated each time I edit or add page.
    So I checked how wordpress does that.
    In wp-admin/edit-pages.php file there is php code that gets pages record from table containg all posts. (pages as I know now are static posts)

    global $wpdb;
    if (isset($user_ID) && ('' != intval($user_ID))) {
    $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static' AND post_author = $user_ID");
    } else {
    $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static'");
    ...
    foreach ($posts as $post) : start_wp();
    <?php the_title() ?>
    <?php the_author() ?></td>
    <?php the_time('Y-m-d g:i a'); ?></td>
    " rel="permalink" class="edit"><?php _e('View'); ?>

    Modifiying that code I can generate dynamically menu to my pages. But it isn't elegant way - or maybe it's the only way to do what I want?
    Maciek KuÅ›, ibex.pl

  7. TechGnome
    Moderator
    Posted 9 years ago #

    maciekkus - a more elegant way would be to take that code and convert it into a plugin. Then in the menu, jsut call the function to display the menu where you want it.
    Tg

  8. Anonymous
    Unregistered
    Posted 9 years ago #

    Hi. just wondering can I use this "page" function to make my site menu?
    I mean, create for each section of my site a PAGE and link it as a menu on the front page?
    T.I.A

  9. Maciej Ku? (maciekkus)
    Member
    Posted 9 years ago #

    @TechGnome
    That's the challenge :)
    @Anonymous:
    It works for me. But I'll try to convert it to plugin (don't know how yet, but I will try :)
    Maciek

  10. Joshua Sigar
    Member
    Posted 9 years ago #

    There is or will be a built-in function to get all pages.

  11. TechGnome
    Moderator
    Posted 9 years ago #

    I kinda figured the devs would get to it at some point. There's a func call for everything else in WP.
    Tg

  12. Leonieke
    Member
    Posted 9 years ago #

    @mdawaffe
    thanks for the quickie link

  13. kharris
    Member
    Posted 9 years ago #

    Luc said:

    in admin :
    1- you create a page
    2- you save it
    3- you go to "manage page" and then you have the usaual 3 links edit/view/delete
    The view link is the url of the page.

    Okay. So far, so good. Oh, and I'm running 1.3A4.

    The page system updates automatically the .htaccess file so you don'y need to manage that manually

    I didn't have a .htacccess, so I created an empty .htaccess and made it 666.

    If you page is supposed to contain php code :
    1- you create the php file using the skeleton of the index.php file in your template and you add at the very beginning of the file
    <?php
    /* Template Name: NAME_OF_THE_PAGE
    2- you create a page but you don't fill the content, instead you choose your php file in the "template" menu

    Okay, this part has me flummoxed. I copied public_html/index.php to public_html/delicious.php and deleted the bits that I don't want - leaving just the three include's for the headers and the footer.
    I put

    /*
    Template Name: Delicious
    Template URI: http://kharris.dotgeek.org/delicious.php
    */

    as the 2nd-5th lines in delicious.php.
    I go back to Page->edit and don't see anything other than "Default Template" on the "Page Template" menu.
    Where did I go wrong?
    thanks-in-advance,
    kevin

  14. Joshua Sigar
    Member
    Posted 9 years ago #

    The following is a sample of page template found in kubrick 1.3. The filename is called archives.php

    <?php /*
    Template Name: Archives
    */
    ?>
    <?php include "header.php"; ?>
    <div id="content" class="widecolumn">
    <?php include "searchform.php"; ?>
    <h2>Archives by Month:</h2>

      <?php wp_get_archives('type=monthly'); ?>

    <h2>Archives by Subject:</h2>

      <?php wp_list_cats(); ?>

    </div>
    <?php include "footer.php"; ?>

  15. kharris
    Member
    Posted 9 years ago #

    I'm still doing something wrong.

    As I mentioned in my earlier post, I've got a bare-bones copy of index.php called delicious.php.

    The first 7 lines of delicious.php look like:

    <?php
    /* Template Name: Delicious
    */
    /* Don"t remove this line. */ require("./wp-blog-header.php");
    include(ABSPATH . "/wp-header.php");
    ?>

    The rest is just stuff that I know works because I can see
    http://kharris.dotgeek.org/delicious.php

    just fine.

    I still don"t get anything more than "Default Template" when I try to set page template in Manage->Pages->edit.

    Should the new template go somewhere other than bloginfo("url")?

    thanks...again,

    kevin

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.